# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
673410 | vjudge1 | Cover (COCI18_cover) | C++14 | 3 ms | 468 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |