#include <bits/stdc++.h>
using namespace std;
long long arr[10001],n;
void initialise(int N, int Q,vector<int> h){
n = N;
for(int i = 1;i<=n;i++){
arr[i] = h[i];
}
}
void cut(int l, int r, int k){
vector<int> v;
for(int i = l;i<=r;i++){
v.push_back(arr[i]);
}
sort(v.begin(),v.end());
vector<int> xd;
int all = 0;
for(int i = v.size()-1;i>=0;i--){
all+=v[i];
xd.push_back(all);
}
reverse(xd.begin(),xd.end());
int nah = 0;
for(int i = v.size()-1;i>=0;i--){
if(i&&v[i]==v[i-1])continue;
int elem = v.size()-i;
if(k-(xd[i]-(elem*v[i]))>=0){
nah = i;
}
}
int elem = v.size()-nah;
long long num = v[nah]-((k-(xd[nah]-(elem*v[nah])))/elem);
long long rem = k-num;
for(int i = l;i<=r;i++){
arr[i] = min(arr[i],num);
if(arr[i]==num&&rem&&arr[i]!=0){
arr[i]--;
rem--;
}
}
}
void magic(int i, int x){
arr[i] = x;
}
long long int inspect(int l, int r){
long long sum = 0;
for(int i = l;i<=r;i++){
sum+=arr[i];
}
return sum;
}
/*
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
initialise(6,1,{0,1,2,3,1,2,3});
cut(1,6,3);
cout<<inspect(1,6)<<endl;
}*/
Compilation message
/usr/bin/ld: /tmp/cc9ZUQu8.o: in function `main':
grader.cpp:(.text.startup+0xe2): undefined reference to `initialise(int, int, int*)'
collect2: error: ld returned 1 exit status