제출 #1063018

#제출 시각아이디문제언어결과실행 시간메모리
1063018antonJobs (BOI24_jobs)C++17
0 / 100
8 ms9512 KiB
#include<bits/stdc++.h> using namespace std; const int MAX_N = 3e5+1; int N, S; vector<int> ch[MAX_N]; int x[MAX_N]; int dfs(int u){ int res= 0; res += x[u]; for(auto e: ch[u]){ res += dfs(e); } return max(0, res); } signed main(){ cin>>N>>S; x[0] = 0; for(int i = 1; i<=N; i++){ int anc; cin>>x[i]>>anc; ch[anc].push_back(i); } cout<<dfs(0)<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...