Submission #3235163
Source Code Expand
#include <iostream> #include<vector> #include<algorithm> using namespace std; typedef long long ll; int main() { int n;cin>>n; vector<ll> x(n),y(n),a(n),b(n); vector<pair<ll,ll>> p(n); for(int i=0;i<n;i++){ cin>>x[i]>>y[i]; a[i]=x[i]; b[i]=y[i]; if(x[i]<y[i]){ a[i]=y[i]; b[i]=x[i]; } p[i].first=a[i]; p[i].second=b[i]; } sort(p.begin(),p.end(),greater<pair<ll,ll>>()); sort(a.begin(),a.end(),greater<ll>()); sort(b.begin(),b.end(),greater<ll>()); ll max=a[0]; ll min=b[n-1]; ll ans=(a[0]-a[n-1])*(b[0]-b[n-1]); ll max2=p[0].second; ll min2=a[n-1]; ll sub=a[0]-a[n-1]; for(int i=0;i<n-1;i++){ if(min2>p[i].second){ min2=p[i].second; } if(max2<p[i].second){ max2=p[i].second; } if(max2<p[i+1].first){ if(sub>p[i+1].first-min2){ sub=p[i+1].first-min2; } }else{ if(sub>max2-min2){ sub=max2-min2; } break; } } if(ans>(max-min)*sub){ ans=(max-min)*sub; } cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Ball Coloring |
User | ator |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1019 Byte |
Status | AC |
Exec Time | 216 ms |
Memory | 11648 KB |
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 | 205 ms | 9600 KB |
div21 | AC | 204 ms | 9600 KB |
div22 | AC | 216 ms | 9600 KB |
div23 | AC | 204 ms | 9600 KB |
div24 | AC | 204 ms | 9600 KB |
example0 | AC | 1 ms | 256 KB |
example1 | AC | 1 ms | 256 KB |
example2 | AC | 1 ms | 256 KB |
maxrand0 | AC | 208 ms | 9600 KB |
maxrand1 | AC | 204 ms | 9600 KB |
maxrand2 | AC | 204 ms | 9600 KB |
maxrand20 | AC | 191 ms | 9600 KB |
maxrand21 | AC | 199 ms | 9600 KB |
maxrand210 | AC | 195 ms | 9600 KB |
maxrand211 | AC | 200 ms | 9600 KB |
maxrand22 | AC | 199 ms | 9600 KB |
maxrand23 | AC | 202 ms | 9600 KB |
maxrand24 | AC | 205 ms | 9600 KB |
maxrand25 | AC | 197 ms | 9600 KB |
maxrand26 | AC | 197 ms | 9600 KB |
maxrand27 | AC | 202 ms | 11648 KB |
maxrand28 | AC | 204 ms | 9600 KB |
maxrand29 | AC | 204 ms | 9600 KB |
maxrand3 | AC | 205 ms | 9600 KB |
maxrand4 | AC | 203 ms | 9600 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 | 195 ms | 9600 KB |
sparse1 | AC | 191 ms | 9600 KB |
sparse2 | AC | 193 ms | 9600 KB |
sparse3 | AC | 202 ms | 9600 KB |
sparse4 | AC | 192 ms | 9600 KB |