Submission #932485

# Submission time Handle Problem Language Result Execution time Memory
932485 2024-02-23T13:42:08 Z andrei_boaca Worst Reporter 4 (JOI21_worst_reporter4) C++17
14 / 100
202 ms 206644 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll INF=1e17;
map<ll,ll> nrm;
ll nr;
vector<ll> muchii[200005];
ll n,par[200005],v[200005],cost[200005];
ll dp[5005][5005];
void dfs(ll nod)
{
    for(ll i:muchii[nod])
    {
        dfs(i);
        for(int j=nr;j>=1;j--)
            dp[nod][j]+=dp[i][j];
    }
    for(int i=1;i<=nr;i++)
        if(i!=v[nod])
            dp[nod][i]+=cost[nod];
    for(int i=v[nod]-1;i>=1;i--)
        dp[nod][i]=min(dp[nod][i],dp[nod][v[nod]]);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    vector<ll> vals;
    for(int i=1;i<=n;i++)
    {
        cin>>par[i]>>v[i]>>cost[i];
        if(i!=1)
            muchii[par[i]].push_back(i);
        vals.push_back(v[i]);
    }
    sort(vals.begin(),vals.end());
    vals.erase(unique(vals.begin(),vals.end()),vals.end());
    for(int i=0;i<vals.size();i++)
        nrm[vals[i]]=i+1;
    nr=vals.size();
    for(int i=1;i<=n;i++)
        v[i]=nrm[v[i]];
    dfs(1);
    cout<<dp[1][1];
    return 0;
}

Compilation message

worst_reporter2.cpp: In function 'int main()':
worst_reporter2.cpp:40:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for(int i=0;i<vals.size();i++)
      |                 ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 10588 KB Output is correct
2 Correct 2 ms 10684 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 2 ms 10588 KB Output is correct
5 Correct 93 ms 206192 KB Output is correct
6 Correct 28 ms 205908 KB Output is correct
7 Correct 26 ms 205908 KB Output is correct
8 Correct 74 ms 206164 KB Output is correct
9 Correct 28 ms 205916 KB Output is correct
10 Correct 24 ms 205844 KB Output is correct
11 Correct 16 ms 104792 KB Output is correct
12 Correct 64 ms 206600 KB Output is correct
13 Correct 26 ms 206216 KB Output is correct
14 Correct 65 ms 206536 KB Output is correct
15 Correct 28 ms 206112 KB Output is correct
16 Correct 65 ms 206164 KB Output is correct
17 Correct 27 ms 205916 KB Output is correct
18 Correct 14 ms 109660 KB Output is correct
19 Correct 69 ms 206316 KB Output is correct
20 Correct 28 ms 205912 KB Output is correct
21 Correct 24 ms 205916 KB Output is correct
22 Correct 64 ms 206032 KB Output is correct
23 Correct 26 ms 205904 KB Output is correct
24 Correct 64 ms 206348 KB Output is correct
25 Correct 27 ms 206040 KB Output is correct
26 Correct 64 ms 206644 KB Output is correct
27 Correct 68 ms 206468 KB Output is correct
28 Correct 67 ms 206420 KB Output is correct
29 Correct 67 ms 206392 KB Output is correct
30 Correct 64 ms 206416 KB Output is correct
31 Correct 64 ms 206420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 10588 KB Output is correct
2 Correct 2 ms 10684 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 2 ms 10588 KB Output is correct
5 Correct 93 ms 206192 KB Output is correct
6 Correct 28 ms 205908 KB Output is correct
7 Correct 26 ms 205908 KB Output is correct
8 Correct 74 ms 206164 KB Output is correct
9 Correct 28 ms 205916 KB Output is correct
10 Correct 24 ms 205844 KB Output is correct
11 Correct 16 ms 104792 KB Output is correct
12 Correct 64 ms 206600 KB Output is correct
13 Correct 26 ms 206216 KB Output is correct
14 Correct 65 ms 206536 KB Output is correct
15 Correct 28 ms 206112 KB Output is correct
16 Correct 65 ms 206164 KB Output is correct
17 Correct 27 ms 205916 KB Output is correct
18 Correct 14 ms 109660 KB Output is correct
19 Correct 69 ms 206316 KB Output is correct
20 Correct 28 ms 205912 KB Output is correct
21 Correct 24 ms 205916 KB Output is correct
22 Correct 64 ms 206032 KB Output is correct
23 Correct 26 ms 205904 KB Output is correct
24 Correct 64 ms 206348 KB Output is correct
25 Correct 27 ms 206040 KB Output is correct
26 Correct 64 ms 206644 KB Output is correct
27 Correct 68 ms 206468 KB Output is correct
28 Correct 67 ms 206420 KB Output is correct
29 Correct 67 ms 206392 KB Output is correct
30 Correct 64 ms 206416 KB Output is correct
31 Correct 64 ms 206420 KB Output is correct
32 Correct 73 ms 206300 KB Output is correct
33 Runtime error 202 ms 57664 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 10588 KB Output is correct
2 Correct 2 ms 10684 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 2 ms 10588 KB Output is correct
5 Correct 93 ms 206192 KB Output is correct
6 Correct 28 ms 205908 KB Output is correct
7 Correct 26 ms 205908 KB Output is correct
8 Correct 74 ms 206164 KB Output is correct
9 Correct 28 ms 205916 KB Output is correct
10 Correct 24 ms 205844 KB Output is correct
11 Correct 16 ms 104792 KB Output is correct
12 Correct 64 ms 206600 KB Output is correct
13 Correct 26 ms 206216 KB Output is correct
14 Correct 65 ms 206536 KB Output is correct
15 Correct 28 ms 206112 KB Output is correct
16 Correct 65 ms 206164 KB Output is correct
17 Correct 27 ms 205916 KB Output is correct
18 Correct 14 ms 109660 KB Output is correct
19 Correct 69 ms 206316 KB Output is correct
20 Correct 28 ms 205912 KB Output is correct
21 Correct 24 ms 205916 KB Output is correct
22 Correct 64 ms 206032 KB Output is correct
23 Correct 26 ms 205904 KB Output is correct
24 Correct 64 ms 206348 KB Output is correct
25 Correct 27 ms 206040 KB Output is correct
26 Correct 64 ms 206644 KB Output is correct
27 Correct 68 ms 206468 KB Output is correct
28 Correct 67 ms 206420 KB Output is correct
29 Correct 67 ms 206392 KB Output is correct
30 Correct 64 ms 206416 KB Output is correct
31 Correct 64 ms 206420 KB Output is correct
32 Correct 73 ms 206300 KB Output is correct
33 Runtime error 202 ms 57664 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -