# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
137474 | 2019-07-28T00:25:09 Z | ahmedie404 | Cover (COCI18_cover) | C++14 | 14 ms | 504 KB |
#include <bits/stdc++.h> #define ff first #define ss second using namespace std; const int maxn = 5e3+10; const long long inf = 2e18+10; typedef pair<int, int> pii; typedef long long ll; int n; int prox[maxn]; ll dp[maxn]; pii pt[maxn]; int main(void) { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d %d", &pt[i].ff, &pt[i].ss); pt[i].ff = abs(pt[i].ff); pt[i].ss = abs(pt[i].ss); } sort(pt+1, pt+n+1); for (int i = 1; i <= n; i++) { for (int j = i-1; j >= 1; j--) { if (pt[j].ss > pt[i].ss) { prox[i] = j; break; } } } for (int i = 1; i <= n; i++) dp[i] = inf; for (int i = 1; i <= n; i++) { int at = i; while (at != 0) { dp[i] = min(dp[i], 3ll*pt[i].ff*pt[at].ss + dp[prox[at]]); at = prox[at]; } } printf("%lld\n", dp[n]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 504 KB | Output isn't correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Incorrect | 2 ms | 376 KB | Output isn't correct |
4 | Incorrect | 2 ms | 256 KB | Output isn't correct |
5 | Incorrect | 2 ms | 256 KB | Output isn't correct |
6 | Incorrect | 2 ms | 252 KB | Output isn't correct |
7 | Incorrect | 2 ms | 376 KB | Output isn't correct |
8 | Incorrect | 3 ms | 376 KB | Output isn't correct |
9 | Incorrect | 7 ms | 504 KB | Output isn't correct |
10 | Incorrect | 14 ms | 504 KB | Output isn't correct |