#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<pair<int, int>> pa;
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y;
pa.emplace_back(abs(x), abs(y));
}
vector<pair<int, int>> pb;
for (int i = 0; i < n; i++) {
bool ok = true;
for (int j = 0; j < n; j++) {
if (pa[j].first > pa[i].first && pa[j].second > pa[i].second) {
ok = false;
}
}
if (ok) {
pb.emplace_back(pa[i]);
}
}
sort(pb.begin(), pb.end());
int m = pb.size();
vector<long long> dp(m + 1, 1e18);
dp[0] = 0;
for (int i = 0; i < m; i++) {
int mxy = 0;
for (int j = i; j >= 0; j--) {
mxy = max(mxy, pb[j].second);
dp[i + 1] = min(dp[i + 1], dp[j] + 1LL * pb[i].first * mxy);
}
cout << dp[i + 1] << ' ';
}
cout << dp[m] * 4;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
324 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
324 KB |
Output isn't correct |
8 |
Incorrect |
4 ms |
340 KB |
Output isn't correct |
9 |
Incorrect |
27 ms |
416 KB |
Output isn't correct |
10 |
Incorrect |
81 ms |
604 KB |
Output isn't correct |