Submission #1695228


Source Code Expand

#include <algorithm>
#include <cstdio>

const int N=200005,inf=1000000000;
int cnt[N];

struct P{
	int v,id;
}q[N*2];

bool cmp(P a,P b){return a.v<b.v;}

int main(){
	int n,max1=0,max2=0,min1=inf,min2=inf,tot=0;
	scanf("%d\n",&n);
	for (int i=1;i<=n;i++){
		int x,y;
		scanf("%d%d\n",&x,&y);
		if (x<y) std::swap(x,y);
		max1=std::max(max1,x);
		max2=std::max(max2,y);
		min1=std::min(min1,x);
		min2=std::min(min2,y);
		q[++tot].v=x;q[tot].id=i;
		q[++tot].v=y;q[tot].id=i;
	}
	long long ans=1ll*(max1-min1)*(max2-min2);
	std::sort(q+1,q+tot+1,cmp);
	for (int i=1,j=1,k=0;i<=tot;i++){
		for (;j<=tot && k<n;j++) k+=!cnt[q[j].id]++;
		if (k<n) break;
		ans=std::min(ans,1ll*(max1-min2)*(q[j-1].v-q[i].v));
		k-=!--cnt[q[i].id];
	}
	printf("%lld\n",ans);
}

Submission Info

Submission Time
Task E - Ball Coloring
User aufeas
Language C++14 (GCC 5.4.1)
Score 700
Code Size 791 Byte
Status AC
Exec Time 92 ms
Memory 4096 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:15:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d\n",&n);
                  ^
./Main.cpp:18:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d\n",&x,&y);
                        ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 35
Set Name Test Cases
Sample example0, example1, example2
All div20, div21, div22, div23, div24, example0, example1, example2, maxrand0, maxrand1, maxrand2, maxrand20, maxrand21, maxrand210, maxrand211, maxrand22, maxrand23, maxrand24, maxrand25, maxrand26, maxrand27, maxrand28, maxrand29, maxrand3, maxrand4, smallrand0, smallrand1, smallrand2, smallrand3, smallrand4, sparse0, sparse1, sparse2, sparse3, sparse4
Case Name Status Exec Time Memory
div20 AC 89 ms 4096 KB
div21 AC 88 ms 4096 KB
div22 AC 88 ms 4096 KB
div23 AC 90 ms 4096 KB
div24 AC 92 ms 4096 KB
example0 AC 1 ms 128 KB
example1 AC 1 ms 128 KB
example2 AC 1 ms 128 KB
maxrand0 AC 88 ms 4096 KB
maxrand1 AC 88 ms 4096 KB
maxrand2 AC 88 ms 4096 KB
maxrand20 AC 75 ms 4096 KB
maxrand21 AC 78 ms 4096 KB
maxrand210 AC 74 ms 4096 KB
maxrand211 AC 79 ms 4096 KB
maxrand22 AC 79 ms 4096 KB
maxrand23 AC 81 ms 4096 KB
maxrand24 AC 88 ms 4096 KB
maxrand25 AC 77 ms 4096 KB
maxrand26 AC 78 ms 4096 KB
maxrand27 AC 83 ms 4096 KB
maxrand28 AC 86 ms 4096 KB
maxrand29 AC 87 ms 4096 KB
maxrand3 AC 87 ms 4096 KB
maxrand4 AC 88 ms 4096 KB
smallrand0 AC 1 ms 128 KB
smallrand1 AC 1 ms 128 KB
smallrand2 AC 1 ms 128 KB
smallrand3 AC 1 ms 128 KB
smallrand4 AC 1 ms 128 KB
sparse0 AC 72 ms 4096 KB
sparse1 AC 72 ms 4096 KB
sparse2 AC 72 ms 4096 KB
sparse3 AC 73 ms 4096 KB
sparse4 AC 71 ms 4096 KB