# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
673409 |
2022-12-20T14:31:48 Z |
vjudge1 |
Cover (COCI18_cover) |
C++14 |
|
3 ms |
468 KB |
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
const int N = 5005;
int n;
long long dp[N];
map<int,int> mp;
vector<pii> myVec;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1, x, y; i <= n; i++) {
cin >> x >> y;
x = abs(x), y = abs(y);
auto it = mp.find(x);
if (it == mp.end()) mp[x] = y;
else mp[x] = max(y, it->se);
}
for (auto it : mp) {
while (!myVec.empty() && it.se >= myVec.back().se)
myVec.pop_back();
myVec.pb(it);
}
n = myVec.size();
for (int i = 0; i < n; i++) {
dp[i] = 4 * myVec[i].fi * myVec[0].se;
for (int j = 0; j < i; j++)
dp[i] = min(dp[i], dp[j] + 4 * myVec[i].fi * myVec[j + 1].se);
}
cout << dp[n - 1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
468 KB |
Output isn't correct |
10 |
Incorrect |
3 ms |
468 KB |
Output isn't correct |