Submission #796427

# Submission time Handle Problem Language Result Execution time Memory
796427 2023-07-28T11:32:19 Z Dan4Life Worst Reporter 4 (JOI21_worst_reporter4) C++17
79 / 100
329 ms 146488 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
const int mxN = (int)2e5+10;
const int LINF = (int)2e18;
int n;
unordered_map<int,int> dp[mxN];
int a[mxN], h[mxN], c[mxN];
vector<int> adj[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);
	}
	int xd = 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; }
	}
	S[s].insert({h[s],xd});
}

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

worst_reporter2.cpp: In function 'void dfs(long long int)':
worst_reporter2.cpp:23:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   23 |   if(itr==begin(S[s])) break; itr--;
      |   ^~
worst_reporter2.cpp:23:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   23 |   if(itr==begin(S[s])) break; itr--;
      |                               ^~~
worst_reporter2.cpp: In function 'int32_t main()':
worst_reporter2.cpp:36:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   36 |   if(i>1) adj[a[i]].pb(i); tot+=c[i];
      |   ^~
worst_reporter2.cpp:36:28: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   36 |   if(i>1) adj[a[i]].pb(i); tot+=c[i];
      |                            ^~~
# Verdict Execution time Memory Grader output
1 Correct 14 ms 25300 KB Output is correct
2 Correct 12 ms 25376 KB Output is correct
3 Correct 13 ms 25300 KB Output is correct
4 Correct 12 ms 25368 KB Output is correct
5 Correct 16 ms 26556 KB Output is correct
6 Correct 18 ms 26680 KB Output is correct
7 Correct 18 ms 26668 KB Output is correct
8 Correct 17 ms 26700 KB Output is correct
9 Correct 14 ms 26664 KB Output is correct
10 Correct 18 ms 26708 KB Output is correct
11 Correct 15 ms 26924 KB Output is correct
12 Correct 14 ms 26408 KB Output is correct
13 Correct 14 ms 26452 KB Output is correct
14 Correct 14 ms 26128 KB Output is correct
15 Correct 14 ms 26152 KB Output is correct
16 Correct 15 ms 27036 KB Output is correct
17 Correct 15 ms 27092 KB Output is correct
18 Correct 15 ms 27564 KB Output is correct
19 Correct 14 ms 26320 KB Output is correct
20 Correct 14 ms 26404 KB Output is correct
21 Correct 13 ms 26476 KB Output is correct
22 Correct 13 ms 26196 KB Output is correct
23 Correct 15 ms 26300 KB Output is correct
24 Correct 15 ms 26312 KB Output is correct
25 Correct 15 ms 26436 KB Output is correct
26 Correct 18 ms 26452 KB Output is correct
27 Correct 15 ms 26384 KB Output is correct
28 Correct 15 ms 26412 KB Output is correct
29 Correct 17 ms 26564 KB Output is correct
30 Correct 15 ms 26580 KB Output is correct
31 Correct 19 ms 26540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 25300 KB Output is correct
2 Correct 12 ms 25376 KB Output is correct
3 Correct 13 ms 25300 KB Output is correct
4 Correct 12 ms 25368 KB Output is correct
5 Correct 16 ms 26556 KB Output is correct
6 Correct 18 ms 26680 KB Output is correct
7 Correct 18 ms 26668 KB Output is correct
8 Correct 17 ms 26700 KB Output is correct
9 Correct 14 ms 26664 KB Output is correct
10 Correct 18 ms 26708 KB Output is correct
11 Correct 15 ms 26924 KB Output is correct
12 Correct 14 ms 26408 KB Output is correct
13 Correct 14 ms 26452 KB Output is correct
14 Correct 14 ms 26128 KB Output is correct
15 Correct 14 ms 26152 KB Output is correct
16 Correct 15 ms 27036 KB Output is correct
17 Correct 15 ms 27092 KB Output is correct
18 Correct 15 ms 27564 KB Output is correct
19 Correct 14 ms 26320 KB Output is correct
20 Correct 14 ms 26404 KB Output is correct
21 Correct 13 ms 26476 KB Output is correct
22 Correct 13 ms 26196 KB Output is correct
23 Correct 15 ms 26300 KB Output is correct
24 Correct 15 ms 26312 KB Output is correct
25 Correct 15 ms 26436 KB Output is correct
26 Correct 18 ms 26452 KB Output is correct
27 Correct 15 ms 26384 KB Output is correct
28 Correct 15 ms 26412 KB Output is correct
29 Correct 17 ms 26564 KB Output is correct
30 Correct 15 ms 26580 KB Output is correct
31 Correct 19 ms 26540 KB Output is correct
32 Correct 17 ms 26584 KB Output is correct
33 Correct 282 ms 93216 KB Output is correct
34 Correct 261 ms 92876 KB Output is correct
35 Correct 280 ms 90240 KB Output is correct
36 Correct 329 ms 92944 KB Output is correct
37 Correct 273 ms 96852 KB Output is correct
38 Correct 287 ms 104572 KB Output is correct
39 Correct 143 ms 69676 KB Output is correct
40 Correct 146 ms 69652 KB Output is correct
41 Correct 175 ms 72760 KB Output is correct
42 Correct 156 ms 55628 KB Output is correct
43 Correct 147 ms 55652 KB Output is correct
44 Correct 274 ms 117696 KB Output is correct
45 Correct 278 ms 117920 KB Output is correct
46 Correct 325 ms 146488 KB Output is correct
47 Correct 226 ms 65540 KB Output is correct
48 Correct 276 ms 69304 KB Output is correct
49 Correct 204 ms 69944 KB Output is correct
50 Correct 236 ms 60912 KB Output is correct
51 Correct 189 ms 60844 KB Output is correct
52 Correct 204 ms 66600 KB Output is correct
53 Correct 249 ms 70484 KB Output is correct
54 Correct 83 ms 69836 KB Output is correct
55 Correct 177 ms 67860 KB Output is correct
56 Correct 144 ms 73168 KB Output is correct
57 Correct 133 ms 75996 KB Output is correct
58 Correct 153 ms 73524 KB Output is correct
59 Correct 152 ms 73548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 25300 KB Output is correct
2 Correct 12 ms 25376 KB Output is correct
3 Correct 13 ms 25300 KB Output is correct
4 Correct 12 ms 25368 KB Output is correct
5 Correct 16 ms 26556 KB Output is correct
6 Correct 18 ms 26680 KB Output is correct
7 Correct 18 ms 26668 KB Output is correct
8 Correct 17 ms 26700 KB Output is correct
9 Correct 14 ms 26664 KB Output is correct
10 Correct 18 ms 26708 KB Output is correct
11 Correct 15 ms 26924 KB Output is correct
12 Correct 14 ms 26408 KB Output is correct
13 Correct 14 ms 26452 KB Output is correct
14 Correct 14 ms 26128 KB Output is correct
15 Correct 14 ms 26152 KB Output is correct
16 Correct 15 ms 27036 KB Output is correct
17 Correct 15 ms 27092 KB Output is correct
18 Correct 15 ms 27564 KB Output is correct
19 Correct 14 ms 26320 KB Output is correct
20 Correct 14 ms 26404 KB Output is correct
21 Correct 13 ms 26476 KB Output is correct
22 Correct 13 ms 26196 KB Output is correct
23 Correct 15 ms 26300 KB Output is correct
24 Correct 15 ms 26312 KB Output is correct
25 Correct 15 ms 26436 KB Output is correct
26 Correct 18 ms 26452 KB Output is correct
27 Correct 15 ms 26384 KB Output is correct
28 Correct 15 ms 26412 KB Output is correct
29 Correct 17 ms 26564 KB Output is correct
30 Correct 15 ms 26580 KB Output is correct
31 Correct 19 ms 26540 KB Output is correct
32 Correct 17 ms 26584 KB Output is correct
33 Correct 282 ms 93216 KB Output is correct
34 Correct 261 ms 92876 KB Output is correct
35 Correct 280 ms 90240 KB Output is correct
36 Correct 329 ms 92944 KB Output is correct
37 Correct 273 ms 96852 KB Output is correct
38 Correct 287 ms 104572 KB Output is correct
39 Correct 143 ms 69676 KB Output is correct
40 Correct 146 ms 69652 KB Output is correct
41 Correct 175 ms 72760 KB Output is correct
42 Correct 156 ms 55628 KB Output is correct
43 Correct 147 ms 55652 KB Output is correct
44 Correct 274 ms 117696 KB Output is correct
45 Correct 278 ms 117920 KB Output is correct
46 Correct 325 ms 146488 KB Output is correct
47 Correct 226 ms 65540 KB Output is correct
48 Correct 276 ms 69304 KB Output is correct
49 Correct 204 ms 69944 KB Output is correct
50 Correct 236 ms 60912 KB Output is correct
51 Correct 189 ms 60844 KB Output is correct
52 Correct 204 ms 66600 KB Output is correct
53 Correct 249 ms 70484 KB Output is correct
54 Correct 83 ms 69836 KB Output is correct
55 Correct 177 ms 67860 KB Output is correct
56 Correct 144 ms 73168 KB Output is correct
57 Correct 133 ms 75996 KB Output is correct
58 Correct 153 ms 73524 KB Output is correct
59 Correct 152 ms 73548 KB Output is correct
60 Correct 14 ms 25300 KB Output is correct
61 Incorrect 11 ms 25336 KB Output isn't correct
62 Halted 0 ms 0 KB -