# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
796431 | 2023-07-28T11:37:05 Z | Dan4Life | Worst Reporter 4 (JOI21_worst_reporter4) | C++17 | 307 ms | 133328 KB |
#include <bits/stdc++.h> using namespace std; #define pb push_back #define int long long #define sz(a) (int)a.size() const int mxN = (int)2e5+10; int n; vector<int> adj[mxN]; int a[mxN], h[mxN], c[mxN]; multiset<pair<int,int>> S[mxN]; void dfs(int s){ for(auto u : adj[s]){ dfs(u); if(sz(S[s])<sz(S[u])) S[s].swap(S[u]); for(auto x : S[u]) S[s].insert(x); } S[s].insert({h[s],c[s]}); while(1){ auto itr = S[s].upper_bound({h[s],-1}); if(itr==begin(S[s])) break; itr--; auto [x,y] = *itr; S[s].erase(itr); if(y<=c[s]) c[s]-=y; else{ S[s].insert({x,y-c[s]}); break; } } } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; int tot = 0; for(int i = 1; i <= n; i++){ cin >> a[i] >> h[i] >> c[i]; if(i>1) adj[a[i]].pb(i); tot+=c[i]; } dfs(1); for(auto [x,y] : S[1]) tot-=y; cout << tot; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 14440 KB | Output is correct |
2 | Correct | 7 ms | 14420 KB | Output is correct |
3 | Correct | 7 ms | 14420 KB | Output is correct |
4 | Correct | 7 ms | 14420 KB | Output is correct |
5 | Correct | 12 ms | 15636 KB | Output is correct |
6 | Correct | 13 ms | 15716 KB | Output is correct |
7 | Correct | 12 ms | 15716 KB | Output is correct |
8 | Correct | 13 ms | 15716 KB | Output is correct |
9 | Correct | 11 ms | 15700 KB | Output is correct |
10 | Correct | 11 ms | 15804 KB | Output is correct |
11 | Correct | 11 ms | 15912 KB | Output is correct |
12 | Correct | 11 ms | 15572 KB | Output is correct |
13 | Correct | 11 ms | 15512 KB | Output is correct |
14 | Correct | 10 ms | 15164 KB | Output is correct |
15 | Correct | 11 ms | 15120 KB | Output is correct |
16 | Correct | 12 ms | 16084 KB | Output is correct |
17 | Correct | 12 ms | 16100 KB | Output is correct |
18 | Correct | 12 ms | 16596 KB | Output is correct |
19 | Correct | 12 ms | 15316 KB | Output is correct |
20 | Correct | 12 ms | 15428 KB | Output is correct |
21 | Correct | 14 ms | 15428 KB | Output is correct |
22 | Correct | 10 ms | 15252 KB | Output is correct |
23 | Correct | 11 ms | 15316 KB | Output is correct |
24 | Correct | 11 ms | 15436 KB | Output is correct |
25 | Correct | 11 ms | 15460 KB | Output is correct |
26 | Correct | 11 ms | 15444 KB | Output is correct |
27 | Correct | 11 ms | 15332 KB | Output is correct |
28 | Correct | 10 ms | 15444 KB | Output is correct |
29 | Correct | 10 ms | 15572 KB | Output is correct |
30 | Correct | 10 ms | 15524 KB | Output is correct |
31 | Correct | 10 ms | 15592 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 14440 KB | Output is correct |
2 | Correct | 7 ms | 14420 KB | Output is correct |
3 | Correct | 7 ms | 14420 KB | Output is correct |
4 | Correct | 7 ms | 14420 KB | Output is correct |
5 | Correct | 12 ms | 15636 KB | Output is correct |
6 | Correct | 13 ms | 15716 KB | Output is correct |
7 | Correct | 12 ms | 15716 KB | Output is correct |
8 | Correct | 13 ms | 15716 KB | Output is correct |
9 | Correct | 11 ms | 15700 KB | Output is correct |
10 | Correct | 11 ms | 15804 KB | Output is correct |
11 | Correct | 11 ms | 15912 KB | Output is correct |
12 | Correct | 11 ms | 15572 KB | Output is correct |
13 | Correct | 11 ms | 15512 KB | Output is correct |
14 | Correct | 10 ms | 15164 KB | Output is correct |
15 | Correct | 11 ms | 15120 KB | Output is correct |
16 | Correct | 12 ms | 16084 KB | Output is correct |
17 | Correct | 12 ms | 16100 KB | Output is correct |
18 | Correct | 12 ms | 16596 KB | Output is correct |
19 | Correct | 12 ms | 15316 KB | Output is correct |
20 | Correct | 12 ms | 15428 KB | Output is correct |
21 | Correct | 14 ms | 15428 KB | Output is correct |
22 | Correct | 10 ms | 15252 KB | Output is correct |
23 | Correct | 11 ms | 15316 KB | Output is correct |
24 | Correct | 11 ms | 15436 KB | Output is correct |
25 | Correct | 11 ms | 15460 KB | Output is correct |
26 | Correct | 11 ms | 15444 KB | Output is correct |
27 | Correct | 11 ms | 15332 KB | Output is correct |
28 | Correct | 10 ms | 15444 KB | Output is correct |
29 | Correct | 10 ms | 15572 KB | Output is correct |
30 | Correct | 10 ms | 15524 KB | Output is correct |
31 | Correct | 10 ms | 15592 KB | Output is correct |
32 | Correct | 12 ms | 15712 KB | Output is correct |
33 | Correct | 283 ms | 81064 KB | Output is correct |
34 | Correct | 273 ms | 80384 KB | Output is correct |
35 | Correct | 283 ms | 77800 KB | Output is correct |
36 | Correct | 287 ms | 80584 KB | Output is correct |
37 | Correct | 272 ms | 83948 KB | Output is correct |
38 | Correct | 293 ms | 92072 KB | Output is correct |
39 | Correct | 138 ms | 57108 KB | Output is correct |
40 | Correct | 148 ms | 57208 KB | Output is correct |
41 | Correct | 157 ms | 60220 KB | Output is correct |
42 | Correct | 138 ms | 43168 KB | Output is correct |
43 | Correct | 136 ms | 43232 KB | Output is correct |
44 | Correct | 289 ms | 105068 KB | Output is correct |
45 | Correct | 263 ms | 104732 KB | Output is correct |
46 | Correct | 307 ms | 133328 KB | Output is correct |
47 | Correct | 227 ms | 52336 KB | Output is correct |
48 | Correct | 219 ms | 56076 KB | Output is correct |
49 | Correct | 197 ms | 56672 KB | Output is correct |
50 | Correct | 236 ms | 48612 KB | Output is correct |
51 | Correct | 187 ms | 48624 KB | Output is correct |
52 | Correct | 194 ms | 53876 KB | Output is correct |
53 | Correct | 222 ms | 57680 KB | Output is correct |
54 | Correct | 78 ms | 56700 KB | Output is correct |
55 | Correct | 147 ms | 55436 KB | Output is correct |
56 | Correct | 127 ms | 60816 KB | Output is correct |
57 | Correct | 130 ms | 63716 KB | Output is correct |
58 | Correct | 154 ms | 60940 KB | Output is correct |
59 | Correct | 152 ms | 60992 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 14440 KB | Output is correct |
2 | Correct | 7 ms | 14420 KB | Output is correct |
3 | Correct | 7 ms | 14420 KB | Output is correct |
4 | Correct | 7 ms | 14420 KB | Output is correct |
5 | Correct | 12 ms | 15636 KB | Output is correct |
6 | Correct | 13 ms | 15716 KB | Output is correct |
7 | Correct | 12 ms | 15716 KB | Output is correct |
8 | Correct | 13 ms | 15716 KB | Output is correct |
9 | Correct | 11 ms | 15700 KB | Output is correct |
10 | Correct | 11 ms | 15804 KB | Output is correct |
11 | Correct | 11 ms | 15912 KB | Output is correct |
12 | Correct | 11 ms | 15572 KB | Output is correct |
13 | Correct | 11 ms | 15512 KB | Output is correct |
14 | Correct | 10 ms | 15164 KB | Output is correct |
15 | Correct | 11 ms | 15120 KB | Output is correct |
16 | Correct | 12 ms | 16084 KB | Output is correct |
17 | Correct | 12 ms | 16100 KB | Output is correct |
18 | Correct | 12 ms | 16596 KB | Output is correct |
19 | Correct | 12 ms | 15316 KB | Output is correct |
20 | Correct | 12 ms | 15428 KB | Output is correct |
21 | Correct | 14 ms | 15428 KB | Output is correct |
22 | Correct | 10 ms | 15252 KB | Output is correct |
23 | Correct | 11 ms | 15316 KB | Output is correct |
24 | Correct | 11 ms | 15436 KB | Output is correct |
25 | Correct | 11 ms | 15460 KB | Output is correct |
26 | Correct | 11 ms | 15444 KB | Output is correct |
27 | Correct | 11 ms | 15332 KB | Output is correct |
28 | Correct | 10 ms | 15444 KB | Output is correct |
29 | Correct | 10 ms | 15572 KB | Output is correct |
30 | Correct | 10 ms | 15524 KB | Output is correct |
31 | Correct | 10 ms | 15592 KB | Output is correct |
32 | Correct | 12 ms | 15712 KB | Output is correct |
33 | Correct | 283 ms | 81064 KB | Output is correct |
34 | Correct | 273 ms | 80384 KB | Output is correct |
35 | Correct | 283 ms | 77800 KB | Output is correct |
36 | Correct | 287 ms | 80584 KB | Output is correct |
37 | Correct | 272 ms | 83948 KB | Output is correct |
38 | Correct | 293 ms | 92072 KB | Output is correct |
39 | Correct | 138 ms | 57108 KB | Output is correct |
40 | Correct | 148 ms | 57208 KB | Output is correct |
41 | Correct | 157 ms | 60220 KB | Output is correct |
42 | Correct | 138 ms | 43168 KB | Output is correct |
43 | Correct | 136 ms | 43232 KB | Output is correct |
44 | Correct | 289 ms | 105068 KB | Output is correct |
45 | Correct | 263 ms | 104732 KB | Output is correct |
46 | Correct | 307 ms | 133328 KB | Output is correct |
47 | Correct | 227 ms | 52336 KB | Output is correct |
48 | Correct | 219 ms | 56076 KB | Output is correct |
49 | Correct | 197 ms | 56672 KB | Output is correct |
50 | Correct | 236 ms | 48612 KB | Output is correct |
51 | Correct | 187 ms | 48624 KB | Output is correct |
52 | Correct | 194 ms | 53876 KB | Output is correct |
53 | Correct | 222 ms | 57680 KB | Output is correct |
54 | Correct | 78 ms | 56700 KB | Output is correct |
55 | Correct | 147 ms | 55436 KB | Output is correct |
56 | Correct | 127 ms | 60816 KB | Output is correct |
57 | Correct | 130 ms | 63716 KB | Output is correct |
58 | Correct | 154 ms | 60940 KB | Output is correct |
59 | Correct | 152 ms | 60992 KB | Output is correct |
60 | Correct | 7 ms | 14420 KB | Output is correct |
61 | Incorrect | 6 ms | 14316 KB | Output isn't correct |
62 | Halted | 0 ms | 0 KB | - |