| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 153794 | arnold518 | Fireworks (APIO16_fireworks) | C++14 | 28 ms | 7928 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 3e5;
int N, M;
vector<pii> adj[MAXN+10];
int dp[MAXN+10][400], ans=987654321;
void dfs(int now)
{
int i, j;
if(now>N)
{
dp[now][0]=0;
for(i=1; i<=300; i++) dp[now][i]=987654321;
return;
}
for(auto nxt : adj[now]) dfs(nxt.first);
for(i=0; i<=300; i++)
{
dp[now][i]=0;
for(auto nxt : adj[now])
{
int t=987654321;
for(j=0; j<=i; j++) t=min(t, dp[nxt.first][j]+abs(i-j-nxt.second));
dp[now][i]+=t;
}
}
}
int main()
{
int i, j;
scanf("%d%d", &N, &M);
for(i=2; i<=N+M; i++)
{
int p, c;
scanf("%d%d", &p, &c);
adj[p].push_back({i, c});
}
dfs(1);
ans=987654321;
for(i=0; i<=300; i++) ans=min(ans, dp[1][i]);
printf("%d", ans);
}
컴파일 시 표준 에러 (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... | ||||
