Submission #1002337

#TimeUsernameProblemLanguageResultExecution timeMemory
1002337Valters07Jobs (BOI24_jobs)C++14
11 / 100
85 ms27988 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt") #define fio ios_base::sync_with_stdio(0);cin.tie(0); #define en cin.close();return 0; #define ll long long #define pb push_back #define fi first #define se second using namespace std; const int N = 3e5+5; vector<int> g[N]; ll a[N], dp[N]; void dfs(int u) { for(auto v:g[u]) dfs(v), dp[u]+=dp[v]; dp[u]=max(0ll,dp[u]+a[u]); } int main() { fio // ifstream cin("in.in"); int n; cin >> n >> a[0]; for(int i = 1;i<=n;i++) { cin >> a[i]; int p; cin >> p; g[p].pb(i); } dfs(0); cout << dp[0]-a[0]; 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...