Submission #1694017
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long LL; struct node{int x,y;}a[200010]; int n; LL ans; multiset <int> S1,S2; bool cmp(node x,node y){return x.x<y.x;} void work() { scanf("%d",&n); if (n==1) {puts("0"); return;} for (int i=1; i<=n; i++) { scanf("%d %d",&a[i].x,&a[i].y); if (a[i].x>a[i].y) swap(a[i].x,a[i].y); S1.insert(a[i].x),S2.insert(a[i].y); } ans=1LL*(*S1.rbegin()-*S1.begin())*(*S2.rbegin()-*S2.begin()); sort(a+1,a+n+1,cmp); for (int i=1; i<=n; i++) { S1.erase(S1.find(a[i].x)),S1.insert(a[i].y); S2.erase(S2.find(a[i].y)),S2.insert(a[i].x); ans=min(ans,1LL*(*S1.rbegin()-*S1.begin())*(*S2.rbegin()-*S2.begin())); } printf("%lld",ans); } int main() { work(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Ball Coloring |
User | YMDragon |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 790 Byte |
Status | AC |
Exec Time | 562 ms |
Memory | 20608 KB |
Compile Error
./Main.cpp: In function ‘void work()’: ./Main.cpp:14:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n); ^ ./Main.cpp:18:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d",&a[i].x,&a[i].y); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 700 | ||||
Status |
|
|
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 | 490 ms | 20608 KB |
div21 | AC | 518 ms | 20608 KB |
div22 | AC | 486 ms | 20608 KB |
div23 | AC | 486 ms | 20608 KB |
div24 | AC | 489 ms | 20608 KB |
example0 | AC | 1 ms | 256 KB |
example1 | AC | 1 ms | 256 KB |
example2 | AC | 1 ms | 256 KB |
maxrand0 | AC | 497 ms | 20608 KB |
maxrand1 | AC | 540 ms | 20608 KB |
maxrand2 | AC | 532 ms | 20608 KB |
maxrand20 | AC | 454 ms | 20608 KB |
maxrand21 | AC | 485 ms | 20608 KB |
maxrand210 | AC | 390 ms | 20608 KB |
maxrand211 | AC | 476 ms | 20608 KB |
maxrand22 | AC | 495 ms | 20608 KB |
maxrand23 | AC | 505 ms | 20608 KB |
maxrand24 | AC | 491 ms | 20608 KB |
maxrand25 | AC | 442 ms | 20608 KB |
maxrand26 | AC | 487 ms | 20608 KB |
maxrand27 | AC | 529 ms | 20608 KB |
maxrand28 | AC | 558 ms | 20608 KB |
maxrand29 | AC | 538 ms | 20608 KB |
maxrand3 | AC | 562 ms | 20608 KB |
maxrand4 | AC | 519 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 | 492 ms | 20608 KB |
sparse1 | AC | 504 ms | 20608 KB |
sparse2 | AC | 490 ms | 20608 KB |
sparse3 | AC | 487 ms | 20608 KB |
sparse4 | AC | 487 ms | 20608 KB |