Submission #1689852


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef pair<int,int> pa;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=1ll*x*x%p)if(k&1)res=1ll*res*x%p;return res;}
const int maxn=2e5+5;
int n;
int minip[maxn],maxip[maxn];
pa w[maxn];
bool cmp(pa a,pa b){return a.w2<b.w2;}
int main(){
	read(n);
//	srand(20);
//	n=3;
	if(n==1)return puts("0"),0;
	rep(i,1,n){
		read(w[i].w1),read(w[i].w2);
//		w[i].w1=rand()%100;
//		w[i].w2=rand()%100;
//		cerr<<w[i].w1<<" "<<w[i].w2<<endl;
		if(w[i].w1>w[i].w2)swap(w[i].w1,w[i].w2);
	}
	sort(w+1,w+n+1);
	int dlt=w[n].w1-w[1].w1,last=w[n].w1;
	sort(w+2,w+n+1,cmp);
	rep(i,1,n)maxip[i]=max(maxip[i-1],w[i].w2);
	minip[0]=1e9+10;rep(i,1,n)minip[i]=min(minip[i-1],w[i].w2);
	ll ans=1ll*dlt*(maxip[n]-minip[n]);
	int mini=w[n].w1,maxi=w[n].w1;
	per(i,n-1,2){
		if(w[i].w2==max(maxi,maxip[i]))
			ans=min(ans,1ll*(w[n].w2-w[1].w1)*(w[i].w2-min(mini,minip[i])));
		mini=min(mini,w[i].w1);
		maxi=max(maxi,w[i].w1);
	}
	mini=min(mini,w[1].w2);
	maxi=max(maxi,w[1].w2);
	ans=min(ans,1ll*(maxi-mini)*(w[n].w2-w[1].w1));
	printf("%lld\n",ans);
	return 0;
}

Submission Info

Submission Time
Task E - Ball Coloring
User Vegetable
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1770 Byte
Status WA
Exec Time 72 ms
Memory 3328 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 3
AC × 29
WA × 6
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 WA 70 ms 3328 KB
div21 WA 70 ms 3328 KB
div22 AC 70 ms 3328 KB
div23 AC 70 ms 3328 KB
div24 AC 70 ms 3328 KB
example0 AC 1 ms 256 KB
example1 AC 1 ms 256 KB
example2 AC 1 ms 256 KB
maxrand0 AC 70 ms 3328 KB
maxrand1 WA 70 ms 3328 KB
maxrand2 AC 70 ms 3328 KB
maxrand20 AC 66 ms 3328 KB
maxrand21 AC 67 ms 3328 KB
maxrand210 AC 62 ms 3328 KB
maxrand211 AC 67 ms 3328 KB
maxrand22 AC 69 ms 3328 KB
maxrand23 AC 71 ms 3328 KB
maxrand24 WA 71 ms 3328 KB
maxrand25 AC 66 ms 3328 KB
maxrand26 AC 67 ms 3328 KB
maxrand27 AC 70 ms 3328 KB
maxrand28 AC 72 ms 3328 KB
maxrand29 AC 71 ms 3328 KB
maxrand3 AC 70 ms 3328 KB
maxrand4 AC 71 ms 3328 KB
smallrand0 AC 1 ms 256 KB
smallrand1 WA 1 ms 256 KB
smallrand2 WA 1 ms 256 KB
smallrand3 AC 1 ms 256 KB
smallrand4 AC 1 ms 256 KB
sparse0 AC 60 ms 3328 KB
sparse1 AC 59 ms 3328 KB
sparse2 AC 59 ms 3328 KB
sparse3 AC 59 ms 3328 KB
sparse4 AC 60 ms 3328 KB