제출 #1051342

#제출 시각아이디문제언어결과실행 시간메모리
1051342pravcoderJobs (BOI24_jobs)C++17
11 / 100
68 ms25024 KiB
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <string> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> v2i; typedef pair<int, int> pi; typedef vector<ll> vl; typedef vector<vl> v2l; #define pb push_back #define mp make_pair #define rep(i, n) for (int i = 0; i < n; i++) //sub 1 vl p; v2i adj; ll dfs(int x) { // use dfs to find the maximum possible profit given that you do job x ll s = p[x]; for (auto a : adj[x]) { s += max(0ll, dfs(a)); } return s; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n; ll s; cin >> n >> s; //if (s < 10e17) return 1; adj.resize(n+1); p.pb(s); ll x, p_i; rep(i, n) { cin >> x >> p_i; adj[p_i].pb(i+1); p.pb(x); } cout << dfs(0) - s << 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...