Submission #1093142

# Submission time Handle Problem Language Result Execution time Memory
1093142 2024-09-26T03:00:35 Z 12345678 Worst Reporter 4 (JOI21_worst_reporter4) C++17
79 / 100
294 ms 119344 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=2e5+5;

#define ll long long

ll n, pa[nx], h[nx], c[nx];
vector<ll> d[nx];
map<ll, ll> mp[nx];

void dfs(int u)
{
    mp[u][0]=c[u];
    for (auto v:d[u])
    {
        dfs(v);
        if (mp[v].size()>mp[u].size()) swap(mp[u], mp[v]);
        for (auto [x, y]:mp[v]) mp[u][x]+=y;
    }
    mp[u][h[u]]+=0;
    mp[u][h[u]+1]+=c[u];
    auto itr=mp[u].find(h[u]);
    ll sm=-c[u], lst=h[u];
    while (1)
    {
        sm+=itr->second;
        if (sm>=0) break;
        itr=mp[u].erase(itr);
        itr--;
    }
    mp[u][itr->first]=sm;
    //cout<<"debug "<<u<<'\n';
    //cout<<"mp ";
    //for (auto x:mp[u]) cout<<x.first<<' '<<x.second<<'\n';
}

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    for (int i=1; i<=n; i++) cin>>pa[i]>>h[i]>>c[i];
    for (int i=2; i<=n; i++) d[pa[i]].push_back(i);
    dfs(1);
    cout<<mp[1].begin()->second;
}

Compilation message

worst_reporter2.cpp: In function 'void dfs(int)':
worst_reporter2.cpp:25:18: warning: unused variable 'lst' [-Wunused-variable]
   25 |     ll sm=-c[u], lst=h[u];
      |                  ^~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14428 KB Output is correct
2 Correct 6 ms 14416 KB Output is correct
3 Correct 6 ms 14428 KB Output is correct
4 Correct 6 ms 14428 KB Output is correct
5 Correct 10 ms 16100 KB Output is correct
6 Correct 10 ms 15708 KB Output is correct
7 Correct 8 ms 15288 KB Output is correct
8 Correct 11 ms 16220 KB Output is correct
9 Correct 10 ms 15708 KB Output is correct
10 Correct 9 ms 15452 KB Output is correct
11 Correct 10 ms 15196 KB Output is correct
12 Correct 9 ms 15964 KB Output is correct
13 Correct 8 ms 15808 KB Output is correct
14 Correct 8 ms 15456 KB Output is correct
15 Correct 8 ms 15592 KB Output is correct
16 Correct 10 ms 16472 KB Output is correct
17 Correct 9 ms 15892 KB Output is correct
18 Correct 9 ms 15196 KB Output is correct
19 Correct 10 ms 15708 KB Output is correct
20 Correct 9 ms 15708 KB Output is correct
21 Correct 8 ms 15452 KB Output is correct
22 Correct 8 ms 15708 KB Output is correct
23 Correct 8 ms 15452 KB Output is correct
24 Correct 9 ms 15708 KB Output is correct
25 Correct 8 ms 15736 KB Output is correct
26 Correct 10 ms 16220 KB Output is correct
27 Correct 9 ms 15708 KB Output is correct
28 Correct 10 ms 15964 KB Output is correct
29 Correct 9 ms 15964 KB Output is correct
30 Correct 10 ms 15964 KB Output is correct
31 Correct 10 ms 15844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14428 KB Output is correct
2 Correct 6 ms 14416 KB Output is correct
3 Correct 6 ms 14428 KB Output is correct
4 Correct 6 ms 14428 KB Output is correct
5 Correct 10 ms 16100 KB Output is correct
6 Correct 10 ms 15708 KB Output is correct
7 Correct 8 ms 15288 KB Output is correct
8 Correct 11 ms 16220 KB Output is correct
9 Correct 10 ms 15708 KB Output is correct
10 Correct 9 ms 15452 KB Output is correct
11 Correct 10 ms 15196 KB Output is correct
12 Correct 9 ms 15964 KB Output is correct
13 Correct 8 ms 15808 KB Output is correct
14 Correct 8 ms 15456 KB Output is correct
15 Correct 8 ms 15592 KB Output is correct
16 Correct 10 ms 16472 KB Output is correct
17 Correct 9 ms 15892 KB Output is correct
18 Correct 9 ms 15196 KB Output is correct
19 Correct 10 ms 15708 KB Output is correct
20 Correct 9 ms 15708 KB Output is correct
21 Correct 8 ms 15452 KB Output is correct
22 Correct 8 ms 15708 KB Output is correct
23 Correct 8 ms 15452 KB Output is correct
24 Correct 9 ms 15708 KB Output is correct
25 Correct 8 ms 15736 KB Output is correct
26 Correct 10 ms 16220 KB Output is correct
27 Correct 9 ms 15708 KB Output is correct
28 Correct 10 ms 15964 KB Output is correct
29 Correct 9 ms 15964 KB Output is correct
30 Correct 10 ms 15964 KB Output is correct
31 Correct 10 ms 15844 KB Output is correct
32 Correct 11 ms 15984 KB Output is correct
33 Correct 294 ms 94728 KB Output is correct
34 Correct 225 ms 69972 KB Output is correct
35 Correct 290 ms 91868 KB Output is correct
36 Correct 221 ms 69852 KB Output is correct
37 Correct 152 ms 51088 KB Output is correct
38 Correct 127 ms 46420 KB Output is correct
39 Correct 156 ms 71508 KB Output is correct
40 Correct 134 ms 71252 KB Output is correct
41 Correct 103 ms 71284 KB Output is correct
42 Correct 148 ms 57168 KB Output is correct
43 Correct 129 ms 57060 KB Output is correct
44 Correct 279 ms 119344 KB Output is correct
45 Correct 208 ms 83540 KB Output is correct
46 Correct 89 ms 46048 KB Output is correct
47 Correct 206 ms 67152 KB Output is correct
48 Correct 114 ms 60156 KB Output is correct
49 Correct 90 ms 60236 KB Output is correct
50 Correct 169 ms 62404 KB Output is correct
51 Correct 99 ms 50116 KB Output is correct
52 Correct 213 ms 68288 KB Output is correct
53 Correct 117 ms 61016 KB Output is correct
54 Correct 181 ms 83796 KB Output is correct
55 Correct 168 ms 69952 KB Output is correct
56 Correct 146 ms 74752 KB Output is correct
57 Correct 135 ms 77652 KB Output is correct
58 Correct 151 ms 75168 KB Output is correct
59 Correct 151 ms 75092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14428 KB Output is correct
2 Correct 6 ms 14416 KB Output is correct
3 Correct 6 ms 14428 KB Output is correct
4 Correct 6 ms 14428 KB Output is correct
5 Correct 10 ms 16100 KB Output is correct
6 Correct 10 ms 15708 KB Output is correct
7 Correct 8 ms 15288 KB Output is correct
8 Correct 11 ms 16220 KB Output is correct
9 Correct 10 ms 15708 KB Output is correct
10 Correct 9 ms 15452 KB Output is correct
11 Correct 10 ms 15196 KB Output is correct
12 Correct 9 ms 15964 KB Output is correct
13 Correct 8 ms 15808 KB Output is correct
14 Correct 8 ms 15456 KB Output is correct
15 Correct 8 ms 15592 KB Output is correct
16 Correct 10 ms 16472 KB Output is correct
17 Correct 9 ms 15892 KB Output is correct
18 Correct 9 ms 15196 KB Output is correct
19 Correct 10 ms 15708 KB Output is correct
20 Correct 9 ms 15708 KB Output is correct
21 Correct 8 ms 15452 KB Output is correct
22 Correct 8 ms 15708 KB Output is correct
23 Correct 8 ms 15452 KB Output is correct
24 Correct 9 ms 15708 KB Output is correct
25 Correct 8 ms 15736 KB Output is correct
26 Correct 10 ms 16220 KB Output is correct
27 Correct 9 ms 15708 KB Output is correct
28 Correct 10 ms 15964 KB Output is correct
29 Correct 9 ms 15964 KB Output is correct
30 Correct 10 ms 15964 KB Output is correct
31 Correct 10 ms 15844 KB Output is correct
32 Correct 11 ms 15984 KB Output is correct
33 Correct 294 ms 94728 KB Output is correct
34 Correct 225 ms 69972 KB Output is correct
35 Correct 290 ms 91868 KB Output is correct
36 Correct 221 ms 69852 KB Output is correct
37 Correct 152 ms 51088 KB Output is correct
38 Correct 127 ms 46420 KB Output is correct
39 Correct 156 ms 71508 KB Output is correct
40 Correct 134 ms 71252 KB Output is correct
41 Correct 103 ms 71284 KB Output is correct
42 Correct 148 ms 57168 KB Output is correct
43 Correct 129 ms 57060 KB Output is correct
44 Correct 279 ms 119344 KB Output is correct
45 Correct 208 ms 83540 KB Output is correct
46 Correct 89 ms 46048 KB Output is correct
47 Correct 206 ms 67152 KB Output is correct
48 Correct 114 ms 60156 KB Output is correct
49 Correct 90 ms 60236 KB Output is correct
50 Correct 169 ms 62404 KB Output is correct
51 Correct 99 ms 50116 KB Output is correct
52 Correct 213 ms 68288 KB Output is correct
53 Correct 117 ms 61016 KB Output is correct
54 Correct 181 ms 83796 KB Output is correct
55 Correct 168 ms 69952 KB Output is correct
56 Correct 146 ms 74752 KB Output is correct
57 Correct 135 ms 77652 KB Output is correct
58 Correct 151 ms 75168 KB Output is correct
59 Correct 151 ms 75092 KB Output is correct
60 Correct 6 ms 14428 KB Output is correct
61 Incorrect 6 ms 14512 KB Output isn't correct
62 Halted 0 ms 0 KB -