Submission #1052837

#TimeUsernameProblemLanguageResultExecution timeMemory
1052837vjudge1Jobs (BOI24_jobs)C++17
11 / 100
58 ms30548 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define vll vector<ll> #define all(x) begin(x),end(x) #define pb push_back const int N=3e5+10; ll pro[N],deg[N],mx[N]; vll ma[N]; void dfs(int x,int p=-1) { mx[x]=pro[x]; for(auto y:ma[x]) { dfs(y,x); mx[x]+=mx[y]; } if(mx[x]<0) mx[x]=0; } void solve() { ll n,s; cin>>n>>s; pro[0]=0; for(int i=1;i<=n;i++) { ll p; cin>>pro[i]>>p; deg[i]++; ma[p].pb(i); } dfs(0); cout<<mx[0]<<endl; } int main() { cin.tie(0);cout.tie(0); ios::sync_with_stdio(0); int t=1; // cin>>t; while(t--) 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...