| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 200151 | Saboon | Cover (COCI18_cover) | C++14 | 9 ms | 504 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5000 + 37;
pair<int,int> p[maxn];
ll dp[maxn];
int main(){
ios_base::sync_with_stdio(false);
int n;
cin >> n;
for (int i = 0; i < n; i++){
int x, y;
cin >> x >> y;
x = abs(x), y = abs(y);
p[i] = {x,y};
}
sort(p, p + n);
vector<int> a;
for (int i = 0; i < n; i++){
while (!a.empty() and p[a.back()].second <= p[i].second)
a.pop_back();
a.push_back(i);
}
n = a.size();
memset(dp, 63, sizeof dp);
dp[0] = 0;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= i; j++){
int X = 2 * p[a[i - 1]].first, Y = 2 * p[a[j - 1]].second;
dp[i] = min(dp[i], dp[j - 1] + 1ll * X * Y);
}
}
cout << dp[n] << '\n';
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
