# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
239841 | MrRobot_28 | Cover (COCI18_cover) | C++17 | 9 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
vector <pair <int, int> > x(n);
for(int i = 0; i < n; i++)
{
cin >> x[i].first >> x[i].second;
x[i].first = abs(x[i].first);
x[i].second = abs(x[i].second);
}
sort(x.begin(), x.end());
vector <pair <int, int> > new_x;
for(int i = 0; i < n; i++)
{
while(new_x.size() > 0 && new_x.back().second <= x[i].second)
{
new_x.pop_back();
}
new_x.push_back(x[i]);
}
int m = new_x.size();
vector <int> dp(m, 1e18);
for(int i = 0; i < m; i++)
{
for(int j = 0; j <= i; j++)
{
if(j == 0)
{
dp[i] = new_x[j].second * new_x[i].first;
}
else
{
dp[i] = min(dp[i], dp[j - 1] + new_x[j].second * new_x[i].first);
}
}
}
cout << dp[m - 1] * 4;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |