제출 #1057193

#제출 시각아이디문제언어결과실행 시간메모리
1057193slivajanJobs (BOI24_jobs)C++17
0 / 100
111 ms24296 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 = 0; FEAC(s, graph[v]) ret += rekurze(s); return max((un)0, ret); } void easy(){ un ret = s; 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...