# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
709735 | Ronin13 | Worst Reporter 4 (JOI21_worst_reporter4) | C++14 | 433 ms | 267692 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
const int nmax = 5001;
vector <vector <int> > g(nmax);
vector <int> vec;
int a[nmax], h[nmax];
ll c[nmax];
ll dp[nmax][nmax];
void dfs(int v, int e){
for(int to : g[v]){
if(to == e) continue;
dfs(to, v);
}
for(int j = vec.size() - 1; j >= 0; j--){
ll C = 0;
if(vec[j] != h[v]){
C = c[v];
}
for(int to : g[v]){
if(to == e) continue;
C += dp[to][j];
}
if(j == vec.size() - 1)
dp[v][j] = C;
else
dp[v][j] = min(dp[v][j + 1], C);
}
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
int n; cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i] >> h[i] >> c[i];
g[a[i]].pb(i);
vec.pb(h[i]);
}
sort(vec.begin(), vec.end());
dfs(1, 1);
cout << dp[1][0];
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... |