Submission #992581

#TimeUsernameProblemLanguageResultExecution timeMemory
992581AbitoWeirdtree (RMI21_weirdtree)C++17
0 / 100
2040 ms5488 KiB
#include "weirdtree.h" #include <bits/stdc++.h> #define ll long long #define pb push_back using namespace std; const int NN=3e5+5; ll n,a[NN]; void initialise(int N, int Q, int h[]) { n=N; for (int i=1;i<=n;i++) a[i]=h[i]; return; } void cut(int l, int r, int k) { while (k>0){ ll mx1=0,mx2=0,f=0,d=0; vector<int> v; for (int i=l;i<=r;i++) mx1=max(mx1,a[i]); if (mx1==0) break; for (int i=l;i<=r;i++){ if (a[i]==mx1){ v.pb(i); f++; } else mx2=max(mx2,a[i]); } //cout<<mx1<<' '<<mx2<<endl; d=(mx1-mx2); if (k>=d*f){ for (auto u:v) a[u]=mx2; k-=d*f; continue; } for (auto u:v) a[u]-=k/f; for (int i=0;i<k%f;i++) a[v[i]]--; break; }return; } void magic(int i, int x) { a[i]=x; return; } long long int inspect(int l, int r) { int sum=0; for (int i=l;i<=r;i++) sum+=a[i]; return sum; }
#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...