Submission #1010152

# Submission time Handle Problem Language Result Execution time Memory
1010152 2024-06-28T11:42:15 Z Unforgettablepl Worst Reporter 4 (JOI21_worst_reporter4) C++17
14 / 100
2000 ms 197088 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<vector<int>> adj(n+1);
    vector<int> H(n+1);
    vector<int> Hs(n+1);
    vector<int> C(n+1);
    int a;cin>>a>>H[1]>>C[1];Hs[1]=H[1];
    for(int i=2;i<=n;i++){
        cin>>a>>H[i]>>C[i];Hs[i]=H[i];
        adj[a].emplace_back(i);
    }
    sort(Hs.begin(),Hs.end());
    Hs.erase(unique(Hs.begin(),Hs.end()),Hs.end());
    int k = Hs.size();
    function<vector<int>(int)> dfs = [&](int x){
        vector<int> DP(k);
        for(int i=0;i<k;i++)if(Hs[i]!=H[x])DP[i]=C[x];
        for(int&i:adj[x]){
            auto curr = dfs(i);
            for(int j=0;j<k;j++)DP[j]+=curr[j];
        }
        for(int i=k-2;i>=0;i--)DP[i]=min(DP[i],DP[i+1]);
        return DP;
    };
    cout << dfs(1)[0] << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 134 ms 1616 KB Output is correct
6 Correct 4 ms 820 KB Output is correct
7 Correct 2 ms 812 KB Output is correct
8 Correct 128 ms 1572 KB Output is correct
9 Correct 4 ms 856 KB Output is correct
10 Correct 2 ms 860 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
12 Correct 212 ms 197088 KB Output is correct
13 Correct 3 ms 1884 KB Output is correct
14 Correct 208 ms 98876 KB Output is correct
15 Correct 5 ms 3028 KB Output is correct
16 Correct 123 ms 1392 KB Output is correct
17 Correct 4 ms 860 KB Output is correct
18 Correct 2 ms 860 KB Output is correct
19 Correct 168 ms 98896 KB Output is correct
20 Correct 5 ms 2904 KB Output is correct
21 Correct 2 ms 1144 KB Output is correct
22 Correct 113 ms 860 KB Output is correct
23 Correct 4 ms 856 KB Output is correct
24 Correct 155 ms 98896 KB Output is correct
25 Correct 5 ms 2904 KB Output is correct
26 Correct 218 ms 196944 KB Output is correct
27 Correct 149 ms 79392 KB Output is correct
28 Correct 176 ms 118612 KB Output is correct
29 Correct 191 ms 157776 KB Output is correct
30 Correct 205 ms 98900 KB Output is correct
31 Correct 220 ms 98968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 134 ms 1616 KB Output is correct
6 Correct 4 ms 820 KB Output is correct
7 Correct 2 ms 812 KB Output is correct
8 Correct 128 ms 1572 KB Output is correct
9 Correct 4 ms 856 KB Output is correct
10 Correct 2 ms 860 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
12 Correct 212 ms 197088 KB Output is correct
13 Correct 3 ms 1884 KB Output is correct
14 Correct 208 ms 98876 KB Output is correct
15 Correct 5 ms 3028 KB Output is correct
16 Correct 123 ms 1392 KB Output is correct
17 Correct 4 ms 860 KB Output is correct
18 Correct 2 ms 860 KB Output is correct
19 Correct 168 ms 98896 KB Output is correct
20 Correct 5 ms 2904 KB Output is correct
21 Correct 2 ms 1144 KB Output is correct
22 Correct 113 ms 860 KB Output is correct
23 Correct 4 ms 856 KB Output is correct
24 Correct 155 ms 98896 KB Output is correct
25 Correct 5 ms 2904 KB Output is correct
26 Correct 218 ms 196944 KB Output is correct
27 Correct 149 ms 79392 KB Output is correct
28 Correct 176 ms 118612 KB Output is correct
29 Correct 191 ms 157776 KB Output is correct
30 Correct 205 ms 98900 KB Output is correct
31 Correct 220 ms 98968 KB Output is correct
32 Correct 149 ms 1548 KB Output is correct
33 Execution timed out 2048 ms 49984 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 134 ms 1616 KB Output is correct
6 Correct 4 ms 820 KB Output is correct
7 Correct 2 ms 812 KB Output is correct
8 Correct 128 ms 1572 KB Output is correct
9 Correct 4 ms 856 KB Output is correct
10 Correct 2 ms 860 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
12 Correct 212 ms 197088 KB Output is correct
13 Correct 3 ms 1884 KB Output is correct
14 Correct 208 ms 98876 KB Output is correct
15 Correct 5 ms 3028 KB Output is correct
16 Correct 123 ms 1392 KB Output is correct
17 Correct 4 ms 860 KB Output is correct
18 Correct 2 ms 860 KB Output is correct
19 Correct 168 ms 98896 KB Output is correct
20 Correct 5 ms 2904 KB Output is correct
21 Correct 2 ms 1144 KB Output is correct
22 Correct 113 ms 860 KB Output is correct
23 Correct 4 ms 856 KB Output is correct
24 Correct 155 ms 98896 KB Output is correct
25 Correct 5 ms 2904 KB Output is correct
26 Correct 218 ms 196944 KB Output is correct
27 Correct 149 ms 79392 KB Output is correct
28 Correct 176 ms 118612 KB Output is correct
29 Correct 191 ms 157776 KB Output is correct
30 Correct 205 ms 98900 KB Output is correct
31 Correct 220 ms 98968 KB Output is correct
32 Correct 149 ms 1548 KB Output is correct
33 Execution timed out 2048 ms 49984 KB Time limit exceeded
34 Halted 0 ms 0 KB -