-
Notifications
You must be signed in to change notification settings - Fork 0
/
A_Era.cpp
58 lines (52 loc) · 1.28 KB
/
A_Era.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
51
52
53
54
55
56
57
58
#include <bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define PI 2*acos(0.0)
#define ll long long int
#define ull unsigned long long int
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define fix(x) cout<<fixed<<setprecision(x)
#define MOD 1e9+7
#define endl ("\n")
#define vector vector<ll>
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/__gcd(a,b)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > pbds;
void solve(){
ll n,ans=0,mx,mn=LLONG_MIN,id=1;
cin>>n;
ll a[n+2];
for(int i=1;i<=n;i++){
cin>>a[i];
// if(a[i]>mn) {
// mn=a[i];
// mx=a[i];
// id=i;
// }
}
// if(mx>=id) cout<<mx-id<<endl;
// else cout<<0<<endl;
for(int i=1;i<=n;i++){
if(a[i]>id){
ans+=(a[i]-id);
id=a[i]+1;
}
else id++;
}
cout<<ans<<endl;
}
int main()
{
FAST
int t;
cin>>t;
while(t--)
{
solve();
}
return 0;
}