-
Notifications
You must be signed in to change notification settings - Fork 0
/
bessie_and_MEX.cpp
50 lines (45 loc) · 973 Bytes
/
bessie_and_MEX.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<bits/stdc++.h>
using namespace std;
int mex(vector<int>arr,int s,int e){
sort(arr.begin(),arr.begin()+e);
for(int i=s;i<e;i++){
if(arr[i]!=i) return i;
}
}
void solve2(){
int n;
cin>>n;
vector<int>arr(n);
for(int i=0;i<n;i++)cin>>arr[i];
vector<int>ans(n+1);
ans[n]=n;
int mini = INT16_MAX;
// reverse(arr.begin(),arr.end());
for(int i=n-1;i>=0;i--){
mini = min(mini,ans[i+1]);
ans[i]=mini-arr[i];
}
for(int i=0;i<n;i++) cout<<ans[i]<<" ";
cout<<endl;
}
void solve(){
int n;
cin>>n;
vector<int>arr(n);
for(int i=0;i<n;i++)cin>>arr[i];
vector<int>ans(n);
for(int i=0;i<n;i++)ans[i]=i;
for(int i =0;i<n;i++){
if(arr[i]+ans[i]>mex(ans,0,i)){
}
else {
}
}
}
int main(){
int t;
cin>>t;
while(t--){
solve2();
}
}