제출 #966884

#제출 시각아이디문제언어결과실행 시간메모리
966884Trisanu_DasWorst Reporter 4 (JOI21_worst_reporter4)C++17
79 / 100
331 ms135516 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define int long long #define sz(a) (int)a.size() const int mxN = (int)2e5+10; int n; vector<int> adj[mxN]; int a[mxN], h[mxN], c[mxN]; multiset<pair<int,int>> S[mxN]; void dfs(int s){ for(auto u : adj[s]){ dfs(u); if(sz(S[s])<sz(S[u])) S[s].swap(S[u]); for(auto x : S[u]) S[s].insert(x); } S[s].insert({h[s],c[s]}); while(1){ auto itr = S[s].upper_bound({h[s],-1}); if(itr==begin(S[s])) break; itr--; auto [x,y] = *itr; S[s].erase(itr); if(y<=c[s]) c[s]-=y; else{ S[s].insert({x,y-c[s]}); break; } } } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; int tot = 0; for(int i = 1; i <= n; i++){ cin >> a[i] >> h[i] >> c[i]; if(i>1) adj[a[i]].pb(i); tot+=c[i]; } dfs(1); for(auto [x,y] : S[1]) tot-=y; cout << tot; }

컴파일 시 표준 에러 (stderr) 메시지

worst_reporter2.cpp: In function 'void dfs(long long int)':
worst_reporter2.cpp:20:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   20 |   if(itr==begin(S[s])) break; itr--;
      |   ^~
worst_reporter2.cpp:20:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   20 |   if(itr==begin(S[s])) break; itr--;
      |                               ^~~
worst_reporter2.cpp: In function 'int32_t main()':
worst_reporter2.cpp:32:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   32 |   if(i>1) adj[a[i]].pb(i); tot+=c[i];
      |   ^~
worst_reporter2.cpp:32:28: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   32 |   if(i>1) adj[a[i]].pb(i); tot+=c[i];
      |                            ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...