# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
45171 | 2018-04-11T15:28:11 Z | erdemkiraz | Fireworks (APIO16_fireworks) | C++11 | 40 ms | 1016 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair < int, int > ii; const int N = 300 + 5; int n, m; vector < ii > v[N]; int dp[N][N], dp2[N]; int main() { scanf("%d %d", &n, &m); for(int i = 2; i <= n + m; i++) { int x, c; scanf("%d %d", &x, &c); v[x].push_back({i, c}); } for(int i = n + 1; i <= n + m; i++) { for(int j = 1; j < N; j++) dp[i][j] = 1e9; } for(int x = n; x >= 1; x--) { for(auto u : v[x]) { for(int i = 0; i < N; i++) { int res = 1e9; for(int j = -u.second; j <= i - u.second; j++) res = min(res, dp[u.first][i - j - u.second] + abs(j)); dp[x][i] += res; } } } int res = 1e9; for(int i = 0; i < N; i++) { res = min(res, dp[1][i]); } printf("%d\n", res); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 4 ms | 436 KB | Output is correct |
3 | Correct | 6 ms | 456 KB | Output is correct |
4 | Correct | 9 ms | 624 KB | Output is correct |
5 | Correct | 11 ms | 796 KB | Output is correct |
6 | Correct | 12 ms | 796 KB | Output is correct |
7 | Correct | 13 ms | 860 KB | Output is correct |
8 | Correct | 15 ms | 868 KB | Output is correct |
9 | Correct | 15 ms | 868 KB | Output is correct |
10 | Correct | 16 ms | 872 KB | Output is correct |
11 | Correct | 19 ms | 872 KB | Output is correct |
12 | Correct | 20 ms | 872 KB | Output is correct |
13 | Correct | 33 ms | 1016 KB | Output is correct |
14 | Correct | 23 ms | 1016 KB | Output is correct |
15 | Correct | 23 ms | 1016 KB | Output is correct |
16 | Correct | 40 ms | 1016 KB | Output is correct |
17 | Correct | 23 ms | 1016 KB | Output is correct |
18 | Correct | 22 ms | 1016 KB | Output is correct |
19 | Correct | 23 ms | 1016 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |