# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
45167 | erdemkiraz | Fireworks (APIO16_fireworks) | C++11 | 31 ms | 1020 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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++)
dp2[i] = 1e9;
for(int i = 0; i < N; i++)
for(int j = -u.second; i - j - u.second >= 0; j++)
dp2[i] = min(dp2[i], dp[u.first][i - j - u.second] + abs(j));
for(int i = 0; i < N; i++)
dp[x][i] += dp2[i];
}
}
int res = 1e9;
for(int i = 0; i < N; i++) {
res = min(res, dp[1][i]);
}
printf("%d\n", res);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |