# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145049 | Mihnea | Cover (COCI18_cover) | C++14 | 16 ms | 1912 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
#include<set>
using namespace std;
long long n,x,y,k;
long long D[20001];
set<pair <long long,long long> >s;
set< pair<long long,long long> >::iterator it;
struct elem{
long long x;
long long y;
};
struct drept{
long long dimx;
long long dimy;
};
drept d[20001];
elem e[20001];
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>x>>y;
s.insert(make_pair(x,y));
s.insert(make_pair(x,-y));
s.insert(make_pair(-x,y));
s.insert(make_pair(-x,-y));
}
n=0;
for(it=s.begin();it!=s.end();it++){
e[++n].x=it->first;
e[n].y=it->second;
}
long long minim=e[1].y;
long long maxim=e[1].y;
int i=2;
for(;i<=n;i++){
if(e[i].x>=0)
break;
if(e[i].x==e[i-1].x){
minim=min(minim,e[i].y);
maxim=max(maxim,e[i].y);
}
else{
if(k==0 || maxim-minim>d[k].dimy){
d[++k].dimx=-2 * e[i-1].x;
d[k].dimy=maxim-minim;
}
minim=e[i].y;
maxim=e[i].y;
}
}
if(k==0 || maxim-minim>d[k].dimy){
d[++k].dimx= -2 * e[i-1].x;
d[k].dimy=maxim-minim;
}
for(i=1;i<=k;i++){
D[i]=d[1].dimx * d[i].dimy;
for(int j=1;j<=i;j++)
D[i]=min(D[i], D[j-1]+d[j].dimx * d[i].dimy);
}
cout<<D[k];
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |