Submission #1057197

#TimeUsernameProblemLanguageResultExecution timeMemory
1057197slivajanJobs (BOI24_jobs)C++17
11 / 100
133 ms27984 KiB
#include <bits/stdc++.h> using namespace std; typedef long long un; typedef vector<un> vuc; #define REP(i, a, b) for (un i = (un)a; i < (un)b; i++) #define FEAC(i, a) for (auto&& i : a) #define vec vector #define ALL(x) (x).begin(), (x).end() vuc penize; vuc predek; vec<vuc> graph; un N, s; un rekurze(un v){ un ret = penize[v]; FEAC(s, graph[v]) ret += rekurze(s); return max((un)0, ret); } void easy(){ un ret = 0; REP(i, 0, N) { if (predek[i] == -1) ret += rekurze(i); } cout << ret; } int main(){ cin >> N >> s; penize = vuc(N); predek = vuc(N); REP(i, 0, N){ cin >> penize[i] >> predek[i]; predek[i]--; } graph = vec<vuc>(N); REP(i, 0, N){ if (predek[i] != -1) graph[predek[i]].push_back(i); } if (s == 1e18) { easy(); } }
#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...