제출 #1049363

#제출 시각아이디문제언어결과실행 시간메모리
1049363aymanrsJobs (BOI24_jobs)C++17
11 / 100
69 ms27428 KiB
#include<bits/stdc++.h> using namespace std; struct node { int p; long long x; vector<node*> l; }; void dfs(node* n){ for(node* c : n->l){ dfs(c); if(c->x > 0) n->x += c->x; } } void solve(){ int n;cin >> n; long long s;cin >> s; node g[n+1]; for(int i = 1;i <= n;i++){ cin >> g[i].x >> g[i].p; g[g[i].p].l.push_back(&g[i]); } g[0].x=0; dfs(&g[0]); cout << g[0].x << '\n'; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); solve(); }
#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...