Submission #3725946


Source Code Expand

#include <set>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=2e5+5,inf=2e9;

multiset<int>R,B;
ll Rmx=-inf,Rmn=inf,Bmx=-inf,Bmn=inf,ans;

int read() {
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return x*f;
}

struct bags {
	int v1,v2;

	bags() {}

	bags(int _v1,int _v2) {
		v1=_v1,v2=_v2;
	}

	bool operator<(const bags &a)const {
		return v1<a.v1;
	}
}p[maxn];

ll calc() {
	return 1ll*(*R.rbegin()-*R.begin())*(*B.rbegin()-*B.begin());
}

int main() {
	int n=read();
	for(int i=1;i<=n;i++) {
		int x=read(),y=read();
		if(x>y)swap(x,y);
		p[i]=bags(x,y);
		R.insert(x),B.insert(y);
	}
	sort(p+1,p+n+1);
	ans=calc();
	for(int i=1;i<=n;i++) {
		int x=p[i].v1,y=p[i].v2;
		R.erase(R.find(x)),B.insert(x);
		B.erase(B.find(y)),R.insert(y);
		ans=min(ans,calc());
	}
	printf("%lld\n",ans);
	return 0;
}

Submission Info

Submission Time
Task E - Ball Coloring
User AKMer
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1028 Byte
Status AC
Exec Time 566 ms
Memory 20608 KB

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 476 ms 20608 KB
div21 AC 484 ms 20608 KB
div22 AC 507 ms 20608 KB
div23 AC 519 ms 20608 KB
div24 AC 501 ms 20608 KB
example0 AC 1 ms 256 KB
example1 AC 1 ms 256 KB
example2 AC 1 ms 256 KB
maxrand0 AC 506 ms 20608 KB
maxrand1 AC 536 ms 20608 KB
maxrand2 AC 478 ms 20608 KB
maxrand20 AC 511 ms 20608 KB
maxrand21 AC 521 ms 20608 KB
maxrand210 AC 419 ms 20608 KB
maxrand211 AC 471 ms 20608 KB
maxrand22 AC 497 ms 20608 KB
maxrand23 AC 518 ms 20608 KB
maxrand24 AC 495 ms 20608 KB
maxrand25 AC 437 ms 20608 KB
maxrand26 AC 481 ms 20608 KB
maxrand27 AC 549 ms 20608 KB
maxrand28 AC 558 ms 20608 KB
maxrand29 AC 566 ms 20608 KB
maxrand3 AC 529 ms 20608 KB
maxrand4 AC 512 ms 20608 KB
smallrand0 AC 1 ms 256 KB
smallrand1 AC 1 ms 256 KB
smallrand2 AC 1 ms 256 KB
smallrand3 AC 1 ms 256 KB
smallrand4 AC 1 ms 256 KB
sparse0 AC 475 ms 20608 KB
sparse1 AC 537 ms 20608 KB
sparse2 AC 483 ms 20608 KB
sparse3 AC 474 ms 20608 KB
sparse4 AC 475 ms 20608 KB