답안 #932481

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
932481 2024-02-23T13:35:17 Z andrei_boaca Worst Reporter 4 (JOI21_worst_reporter4) C++17
14 / 100
226 ms 206652 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=nr-1;i>=1;i--)
        dp[nod][i]=min(dp[nod][i],dp[nod][i+1]);
}
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++)
      |                 ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 10588 KB Output is correct
2 Correct 2 ms 10588 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 2 ms 10588 KB Output is correct
5 Correct 155 ms 206216 KB Output is correct
6 Correct 29 ms 205716 KB Output is correct
7 Correct 27 ms 205804 KB Output is correct
8 Correct 142 ms 206136 KB Output is correct
9 Correct 28 ms 205912 KB Output is correct
10 Correct 27 ms 205916 KB Output is correct
11 Correct 16 ms 104784 KB Output is correct
12 Correct 132 ms 206652 KB Output is correct
13 Correct 26 ms 206164 KB Output is correct
14 Correct 136 ms 206372 KB Output is correct
15 Correct 28 ms 205908 KB Output is correct
16 Correct 134 ms 206300 KB Output is correct
17 Correct 28 ms 205904 KB Output is correct
18 Correct 14 ms 109644 KB Output is correct
19 Correct 131 ms 206420 KB Output is correct
20 Correct 27 ms 205908 KB Output is correct
21 Correct 25 ms 205908 KB Output is correct
22 Correct 131 ms 206264 KB Output is correct
23 Correct 27 ms 205904 KB Output is correct
24 Correct 141 ms 206384 KB Output is correct
25 Correct 28 ms 205876 KB Output is correct
26 Correct 134 ms 206560 KB Output is correct
27 Correct 136 ms 206340 KB Output is correct
28 Correct 136 ms 206316 KB Output is correct
29 Correct 134 ms 206436 KB Output is correct
30 Correct 133 ms 206552 KB Output is correct
31 Correct 130 ms 206476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 10588 KB Output is correct
2 Correct 2 ms 10588 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 2 ms 10588 KB Output is correct
5 Correct 155 ms 206216 KB Output is correct
6 Correct 29 ms 205716 KB Output is correct
7 Correct 27 ms 205804 KB Output is correct
8 Correct 142 ms 206136 KB Output is correct
9 Correct 28 ms 205912 KB Output is correct
10 Correct 27 ms 205916 KB Output is correct
11 Correct 16 ms 104784 KB Output is correct
12 Correct 132 ms 206652 KB Output is correct
13 Correct 26 ms 206164 KB Output is correct
14 Correct 136 ms 206372 KB Output is correct
15 Correct 28 ms 205908 KB Output is correct
16 Correct 134 ms 206300 KB Output is correct
17 Correct 28 ms 205904 KB Output is correct
18 Correct 14 ms 109644 KB Output is correct
19 Correct 131 ms 206420 KB Output is correct
20 Correct 27 ms 205908 KB Output is correct
21 Correct 25 ms 205908 KB Output is correct
22 Correct 131 ms 206264 KB Output is correct
23 Correct 27 ms 205904 KB Output is correct
24 Correct 141 ms 206384 KB Output is correct
25 Correct 28 ms 205876 KB Output is correct
26 Correct 134 ms 206560 KB Output is correct
27 Correct 136 ms 206340 KB Output is correct
28 Correct 136 ms 206316 KB Output is correct
29 Correct 134 ms 206436 KB Output is correct
30 Correct 133 ms 206552 KB Output is correct
31 Correct 130 ms 206476 KB Output is correct
32 Correct 141 ms 206164 KB Output is correct
33 Runtime error 226 ms 57704 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 10588 KB Output is correct
2 Correct 2 ms 10588 KB Output is correct
3 Correct 2 ms 10588 KB Output is correct
4 Correct 2 ms 10588 KB Output is correct
5 Correct 155 ms 206216 KB Output is correct
6 Correct 29 ms 205716 KB Output is correct
7 Correct 27 ms 205804 KB Output is correct
8 Correct 142 ms 206136 KB Output is correct
9 Correct 28 ms 205912 KB Output is correct
10 Correct 27 ms 205916 KB Output is correct
11 Correct 16 ms 104784 KB Output is correct
12 Correct 132 ms 206652 KB Output is correct
13 Correct 26 ms 206164 KB Output is correct
14 Correct 136 ms 206372 KB Output is correct
15 Correct 28 ms 205908 KB Output is correct
16 Correct 134 ms 206300 KB Output is correct
17 Correct 28 ms 205904 KB Output is correct
18 Correct 14 ms 109644 KB Output is correct
19 Correct 131 ms 206420 KB Output is correct
20 Correct 27 ms 205908 KB Output is correct
21 Correct 25 ms 205908 KB Output is correct
22 Correct 131 ms 206264 KB Output is correct
23 Correct 27 ms 205904 KB Output is correct
24 Correct 141 ms 206384 KB Output is correct
25 Correct 28 ms 205876 KB Output is correct
26 Correct 134 ms 206560 KB Output is correct
27 Correct 136 ms 206340 KB Output is correct
28 Correct 136 ms 206316 KB Output is correct
29 Correct 134 ms 206436 KB Output is correct
30 Correct 133 ms 206552 KB Output is correct
31 Correct 130 ms 206476 KB Output is correct
32 Correct 141 ms 206164 KB Output is correct
33 Runtime error 226 ms 57704 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -