Submission #932479

#TimeUsernameProblemLanguageResultExecution timeMemory
932479andrei_boacaWorst Reporter 4 (JOI21_worst_reporter4)C++17
14 / 100
198 ms206684 KiB
#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); ll minim=INF; for(int j=nr;j>=1;j--) { minim=min(minim,dp[i][j]); dp[nod][j]+=minim; } } for(int i=1;i<=nr;i++) if(i!=v[nod]) dp[nod][i]+=cost[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); ll ans=INF; for(ll i=1;i<=nr;i++) ans=min(ans,dp[1][i]); cout<<ans; return 0; }

Compilation message (stderr)

worst_reporter2.cpp: In function 'int main()':
worst_reporter2.cpp:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(int i=0;i<vals.size();i++)
      |                 ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...