Submission #994629

#TimeUsernameProblemLanguageResultExecution timeMemory
994629MisalignedDivJobs (BOI24_jobs)C++14
0 / 100
1 ms604 KiB
#include <iostream> #include <bits/stdc++.h> #include <map> #include <vector> #include <cmath> #include <algorithm> #include <unistd.h> #include <cstdio> using namespace std; typedef long long ll; typedef unsigned int uint; typedef pair<ll, int> pil; typedef vector<int> vi; typedef long long ll; typedef pair<ll,ll> pll; const int SS = 1007; class Solution{ public: ll N, S, xi, pi; vector<ll> profit = {0}, childs[SS]; ll helper(ll curr){ ll res = profit[curr]; for (auto& i: childs[curr]){ res += helper(i); } return max(res, 0LL); } ll profitProfit(){ cin >> N >> S; for (int i = 1; i <= N; i++){ cin >> xi >> pi; childs[pi].push_back(i); profit.push_back( xi ); } return helper(0); } }; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); Solution p; cout << p.profitProfit(); }
#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...