Submission #1059001

#TimeUsernameProblemLanguageResultExecution timeMemory
1059001TonylJobs (BOI24_jobs)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int ll using vi = vector<int>; using pi = pair<ll,ll>; #define REP(i,n) for (int i = 0; i < n; i++) #define trav(a,x) for (auto& a : x) #define //D(x) cerr << #x << ": " << x << endl; #define all(x) (x).begin(), (x).end() const int MAX_N = 3*1e5+3; int n; ll s; vi children[MAX_N]; int values[MAX_N]; bool done[MAX_N]; priority_queue<pi, vector<pi>, greater<pi>> q; ll mineq = 0; void dfs(int i, ll neq, ll pos, bool prev_pos) { assert(!done[i]); done[i] = 1; if (values[i] >= 0) pos += values[i]; if ((values[i] < 0 && prev_pos) || children[i].size() == 0) { if (pos > neq) { q.push({max(mineq,neq), pos-neq}); mineq = max(mineq,neq); pos = 0; neq = 0; } } if (values[i] < 0) neq += -values[i]; if (children[i].size()) dfs(children[i][0], neq, pos, values[i]>=0); } ll triv_dfs(int i) { done[i] = 1; ll tot = values[i]; trav(ch, children[i]) tot += triv_dfs(ch); return max(tot, 0ll); } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> s; ll ss = s; assert(n < MAX_N); REP(i,n) { int p; cin >> values[i] >> p; if (p == 0) continue; p--; children[p].push_back(i); } REP(i,n) { if (done[i]) continue; mineq=0; dfs(i,0,0,0); } while (q.size()) { auto r = q.top(); q.pop(); D(r.first); D(r.second); if (r.first <= s) s += r.second; //else break; } assert(s >= ss); cout << s - ss << endl; return 0; }

Compilation message (stderr)

Main.cpp:9:48: error: no macro name given in #define directive
    9 | #define //D(x) cerr << #x << ": " << x << endl;
      |                                                ^
Main.cpp: In function 'int main()':
Main.cpp:73:9: error: 'D' was not declared in this scope
   73 |         D(r.first);
      |         ^