Submission #639680

#TimeUsernameProblemLanguageResultExecution timeMemory
639680classicCover (COCI18_cover)C++14
120 / 120
77 ms408 KiB
#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[m] * 4; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...