Submission #709735

# Submission time Handle Problem Language Result Execution time Memory
709735 2023-03-14T09:46:36 Z Ronin13 Worst Reporter 4 (JOI21_worst_reporter4) C++14
14 / 100
433 ms 267692 KB
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
const int nmax = 5001;
vector <vector <int> > g(nmax);
vector <int> vec;
int a[nmax], h[nmax];
ll c[nmax];
ll dp[nmax][nmax];

void dfs(int v, int e){
    for(int to : g[v]){
        if(to == e) continue;
        dfs(to, v);
    }
    for(int j = vec.size() - 1; j >= 0; j--){
        ll C = 0;
        if(vec[j] != h[v]){
            C = c[v];
        }
        for(int to : g[v]){
            if(to == e) continue;
            C += dp[to][j];
        }
        if(j == vec.size() - 1)
            dp[v][j] = C;
        else
        dp[v][j] = min(dp[v][j + 1], C);
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i] >> h[i] >> c[i];
        g[a[i]].pb(i);
        vec.pb(h[i]);
    }
    sort(vec.begin(), vec.end());
    dfs(1, 1);
    cout << dp[1][0];
    return 0;
}

Compilation message

worst_reporter2.cpp: In function 'void dfs(int, int)':
worst_reporter2.cpp:32:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         if(j == vec.size() - 1)
      |            ~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 456 KB Output is correct
5 Correct 172 ms 196404 KB Output is correct
6 Correct 169 ms 196384 KB Output is correct
7 Correct 166 ms 196312 KB Output is correct
8 Correct 184 ms 196528 KB Output is correct
9 Correct 161 ms 196372 KB Output is correct
10 Correct 168 ms 196420 KB Output is correct
11 Correct 164 ms 196428 KB Output is correct
12 Correct 154 ms 196856 KB Output is correct
13 Correct 155 ms 196876 KB Output is correct
14 Correct 165 ms 196668 KB Output is correct
15 Correct 177 ms 196668 KB Output is correct
16 Correct 161 ms 196344 KB Output is correct
17 Correct 169 ms 196412 KB Output is correct
18 Correct 169 ms 196464 KB Output is correct
19 Correct 156 ms 196732 KB Output is correct
20 Correct 165 ms 196556 KB Output is correct
21 Correct 164 ms 196656 KB Output is correct
22 Correct 418 ms 196408 KB Output is correct
23 Correct 433 ms 196656 KB Output is correct
24 Correct 287 ms 196576 KB Output is correct
25 Correct 286 ms 196628 KB Output is correct
26 Correct 152 ms 196856 KB Output is correct
27 Correct 176 ms 196528 KB Output is correct
28 Correct 197 ms 196660 KB Output is correct
29 Correct 167 ms 196868 KB Output is correct
30 Correct 172 ms 196524 KB Output is correct
31 Correct 171 ms 196604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 456 KB Output is correct
5 Correct 172 ms 196404 KB Output is correct
6 Correct 169 ms 196384 KB Output is correct
7 Correct 166 ms 196312 KB Output is correct
8 Correct 184 ms 196528 KB Output is correct
9 Correct 161 ms 196372 KB Output is correct
10 Correct 168 ms 196420 KB Output is correct
11 Correct 164 ms 196428 KB Output is correct
12 Correct 154 ms 196856 KB Output is correct
13 Correct 155 ms 196876 KB Output is correct
14 Correct 165 ms 196668 KB Output is correct
15 Correct 177 ms 196668 KB Output is correct
16 Correct 161 ms 196344 KB Output is correct
17 Correct 169 ms 196412 KB Output is correct
18 Correct 169 ms 196464 KB Output is correct
19 Correct 156 ms 196732 KB Output is correct
20 Correct 165 ms 196556 KB Output is correct
21 Correct 164 ms 196656 KB Output is correct
22 Correct 418 ms 196408 KB Output is correct
23 Correct 433 ms 196656 KB Output is correct
24 Correct 287 ms 196576 KB Output is correct
25 Correct 286 ms 196628 KB Output is correct
26 Correct 152 ms 196856 KB Output is correct
27 Correct 176 ms 196528 KB Output is correct
28 Correct 197 ms 196660 KB Output is correct
29 Correct 167 ms 196868 KB Output is correct
30 Correct 172 ms 196524 KB Output is correct
31 Correct 171 ms 196604 KB Output is correct
32 Runtime error 313 ms 267692 KB Execution killed with signal 11
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 456 KB Output is correct
5 Correct 172 ms 196404 KB Output is correct
6 Correct 169 ms 196384 KB Output is correct
7 Correct 166 ms 196312 KB Output is correct
8 Correct 184 ms 196528 KB Output is correct
9 Correct 161 ms 196372 KB Output is correct
10 Correct 168 ms 196420 KB Output is correct
11 Correct 164 ms 196428 KB Output is correct
12 Correct 154 ms 196856 KB Output is correct
13 Correct 155 ms 196876 KB Output is correct
14 Correct 165 ms 196668 KB Output is correct
15 Correct 177 ms 196668 KB Output is correct
16 Correct 161 ms 196344 KB Output is correct
17 Correct 169 ms 196412 KB Output is correct
18 Correct 169 ms 196464 KB Output is correct
19 Correct 156 ms 196732 KB Output is correct
20 Correct 165 ms 196556 KB Output is correct
21 Correct 164 ms 196656 KB Output is correct
22 Correct 418 ms 196408 KB Output is correct
23 Correct 433 ms 196656 KB Output is correct
24 Correct 287 ms 196576 KB Output is correct
25 Correct 286 ms 196628 KB Output is correct
26 Correct 152 ms 196856 KB Output is correct
27 Correct 176 ms 196528 KB Output is correct
28 Correct 197 ms 196660 KB Output is correct
29 Correct 167 ms 196868 KB Output is correct
30 Correct 172 ms 196524 KB Output is correct
31 Correct 171 ms 196604 KB Output is correct
32 Runtime error 313 ms 267692 KB Execution killed with signal 11
33 Halted 0 ms 0 KB -