제출 #1027816

#제출 시각아이디문제언어결과실행 시간메모리
1027816AbitoJobs (BOI24_jobs)C++17
0 / 100
82 ms24144 KiB
#include <bits/stdc++.h> #define F first #define S second #define pb push_back #define ppb pop_back #define ep insert #define endl '\n' #define elif else if #define pow pwr #define sqrt sqrtt #define int long long #define ll long long #define y1 YONE typedef unsigned long long ull; using namespace std; const int N=3e5+5; int a[N],n,dp[N]; vector<int> adj[N]; int dfs(int x){ dp[x]=a[x]; for (auto u:adj[x]) dp[x]+=max(0LL,dfs(u)); return dp[x]; } int32_t main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); cin>>n>>a[0]; for (int i=1;i<=n;i++){ cin>>a[i]; int p;cin>>p; adj[p].pb(i); } cout<<dfs(0)<<endl; return 0; }
#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...