# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
142507 | KCSC | Cover (COCI18_cover) | C++14 | 30 ms | 504 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 <bits/stdc++.h>
using namespace std;
const int DIM = 5005;
long long dp[DIM];
pair<int, int> pts[DIM];
int main(void) {
// freopen("cover.in", "r", stdin);
// freopen("cover.out", "w", stdout);
int n;
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> pts[i].first >> pts[i].second;
if (pts[i].first < 0)
pts[i].first *= -1;
if (pts[i].second < 0)
pts[i].second *= -1;
}
sort(pts + 1, pts + n + 1);
for (int i = 1; i <= n; ++i) {
dp[i] = 1LL << 60;
for (int j = i, v = pts[i].second; j >= 1; --j) {
v = max(v, pts[j].second);
dp[i] = min(dp[i], dp[j - 1] + 4LL * v * pts[i].first);
}
}
cout << dp[n];
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |