| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 673410 | vjudge1 | Cover (COCI18_cover) | C++14 | 3 ms | 468 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;
#define ll long long
#define fi first
#define se second
#define pii pair<ll,ll>
#define pb push_back
const int N = 5005;
int n;
ll 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 | 
|---|---|---|---|---|
| Fetching results... | ||||
