Submission #743953

#TimeUsernameProblemLanguageResultExecution timeMemory
743953jamezzzWeirdtree (RMI21_weirdtree)C++17
13 / 100
23 ms10544 KiB
#include "weirdtree.h" #include <bits/stdc++.h> using namespace std; #ifdef DEBUG #define dbg(...) printf(__VA_ARGS__); #else #define dbg(...) #endif #define sf scanf #define pf printf #define fi first #define se second #define pb push_back #define sz(x) (int)x.size() #define all(x) x.begin(),x.end() #define INF 1023456789 typedef long long ll; typedef pair<int,int> ii; #define maxn 300005 int n,q,h[maxn]; void initialise(int N,int Q,int H[]){ n=N,q=Q; for(int i=1;i<=n;++i)h[i]=H[i]; } void cut(int l,int r,int k){ if(n<=1000&&q<=1000){ vector<int> v; for(int i=l;i<=r;++i)v.pb(h[i]); v.pb(0); sort(all(v)); int num=0,mn=v.back(),rem=k; while(!v.empty()){ int x=v.back(); if((ll)num*(mn-x)<=rem){ rem-=num*(mn-x); ++num; mn=x; v.pop_back(); } else{ int sub=rem/num; mn-=sub; rem-=sub*num; break; } } int cnt=0; for(int i=l;i<=r;++i){ if(h[i]>=mn){ if(cnt<rem)h[i]=mn-1; else h[i]=mn; ++cnt; } h[i]=max(h[i],0); } } } void magic(int i,int x){ if(n<=1000&&q<=1000){ h[i]=x; } } ll inspect(int l,int r){ if(n<=1000&&q<=1000){ ll ans=0; for(int i=l;i<=r;++i)ans+=h[i]; return ans; } return -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...