# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
994688 | PenguinsAreCute | Jobs (BOI24_jobs) | C++17 | 158 ms | 21588 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 314159;
int pr[MAXN];
vector<int> adj[MAXN];
int dfs(int x) {
int ans = pr[x];
for(auto i: adj[x]) ans += dfs(i);
return max(0LL,ans);
}
main() {
int n, s; cin >> n >> s;
for(int i=1,p;i<=n;i++) {cin>>pr[i]>>p; adj[p].push_back(i);}
cout << dfs(0);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |