Submission #709735

#TimeUsernameProblemLanguageResultExecution timeMemory
709735Ronin13Worst Reporter 4 (JOI21_worst_reporter4)C++14
14 / 100
433 ms267692 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...