Submission #743987

#TimeUsernameProblemLanguageResultExecution timeMemory
743987beepbeepsheepWeirdtree (RMI21_weirdtree)C++17
13 / 100
2076 ms6352 KiB
#include "weirdtree.h" #include <bits/stdc++.h> #define ll long long #define ii pair<ll,ll> #define cerr if (0) cerr using namespace std; ll n; vector<ll> v; void initialise(int N, int Q, int H[]) { // Your code here. n=N; v.emplace_back(0); for (int i=1;i<=N;i++){ v.emplace_back(H[i]); } } void cut(int l, int r, int k) { ll lb=0,rb=1000000000,mb; while (lb!=rb-1){ mb=(lb+rb)>>1; ll ans=0; for (int i=l;i<=r;i++){ ans+=max(v[i]-mb,0LL); } if (ans>=k) lb=mb; else rb=mb; } ll s=l,e=r+2,m; while (s!=e-1){ m=(s+e)>>1; ll ans=0; for (int i=l;i<m;i++){ ans+=max(v[i]-lb,0LL); } for (int i=m;i<=r;i++){ ans+=max(v[i]-lb-1,0LL); } if (ans>k) e=m; else s=m; } for (int i=l;i<s;i++){ v[i]=min(lb,v[i]); } for (int i=s;i<=r;i++){ v[i]=min(lb+1,v[i]); } // Your code here. } void magic(int i, int x) { v[i]=x; // Your code here. } long long int inspect(int l, int r) { // Your code here. ll ans=0; for (int i=l;i<=r;i++){ ans+=v[i]; } return ans; }
#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...