#include <iostream>
#include <set>
using namespace std;
struct elem {
int x;
int y;
};
struct dreptunghi {
int dimx;
int dimy;
};
set<pair<int, int> > s;
elem v[20010];
dreptunghi d[20010];
int n, k, i, x, y, minim, maxim, sol;
int sp[20010], SP[20010];
int main () {
cin>>n;
for (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 (set<pair<int, int> >::iterator it = s.begin(); it!=s.end(); it++) {
v[++n].x = it->first;
v[n].y = it->second;
}
minim = v[1].y;
maxim = v[1].y;
for (i=2;i<=n;i++) {
if (v[i].x > 0)
break;
if (v[i].x == v[i-1].x) {
maxim = max(maxim, v[i].y);
minim = min(minim, v[i].y);
} else {
if (k == 0 || maxim-minim > d[k-1].dimy) {
d[++k].dimx = -v[i-1].x*2;
d[k].dimy = maxim - minim;
maxim = v[i].y;
minim = v[i].y;
}
}
}
if (k == 0 || maxim-minim > d[k].dimy) {
d[++k].dimx = -v[i-1].x * 2;
d[k].dimy = maxim - minim;
}
sp[1] = d[1].dimx * d[1].dimy;
for (i=2;i<=k;i++)
sp[i] = d[i].dimx * d[i].dimy + sp[i-1];
SP[k] = d[k].dimx * d[k].dimy;
for (i=k-1;i>=1;i--)
SP[i] = d[i].dimx * d[i].dimy + SP[i+1];
/**
minx = -d[1].dimx/2;
maxx = -minx
miny = -d[k].dimy/2;
maxy = -miny;
**/
sol = d[1].dimx * d[k].dimy;
for (i=1;i<=k;i++)
sol = min(sol, sp[i-1] + d[i].dimx * d[k].dimy);
for (i=k;i>=1;i--)
sol = min(sol, SP[i+1] + d[i].dimy * d[1].dimx);
cout<<sol;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
252 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
7 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
8 |
Incorrect |
4 ms |
632 KB |
Output isn't correct |
9 |
Incorrect |
9 ms |
1016 KB |
Output isn't correct |
10 |
Incorrect |
14 ms |
1528 KB |
Output isn't correct |