# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
996777 | boyliguanhan | Worst Reporter 4 (JOI21_worst_reporter4) | C++17 | 319 ms | 71440 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define N 200100
#define int long long
int gonext[N],h[N],c[N],vis[N],ans;
vector<int>adj[N];
map<int,int>mp[N];
void merge(int a,int b){
if(mp[a].size()<mp[b].size())
swap(mp[a],mp[b]);
for(auto[i,j]:mp[b])
mp[a][i]+=j;
mp[b].clear();
}
void dfs(int n,int p,int q=1){
vis[n]=1;
for(auto i:adj[n])if(i-p)
dfs(i,n),merge(n,i);
mp[n][h[n]+1]+=c[n];
mp[n][h[n]];
mp[n][0]+=c[n];
if(q){
auto it=mp[n].lower_bound(h[n]);
while(it->second<c[n]){
prev(it)->second+=it->second;
it=--mp[n].erase(it);
}
it->second-=c[n];
} else mp[n][h[n]]-=c[n];
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |