-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Mainak_and_Array.cpp
More file actions
42 lines (35 loc) · 967 Bytes
/
Copy pathA_Mainak_and_Array.cpp
File metadata and controls
42 lines (35 loc) · 967 Bytes
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
#include <bits/stdc++.h>
using namespace std;
#define yes {cout<<"YES"<<endl;}
#define no {cout<<"NO"<<endl;}
#define int long long
#define endl '\n';
#define all(x) x.begin(),x.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
int lcm(int a,int b) { return a/__gcd(a,b)*b; }
int nxt(){ int x; cin>>x; return x;}
const int MOD = 1e9 + 7;
void solve(){
int n; cin>>n;
vector<int> v(n);
for(auto &it : v) cin>>it;
int ans = v[n-1] - v[0];
rep(i,0,n){
ans = max(ans,v[(i-1+n)%n]-v[i]);
}
rep(i,1,n){
ans = max(ans,v[n-1]-v[i]);
}
rep(i,1,n){
ans = max(ans,v[i]-v[0]);
}
cout << ans << endl;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t; cin >> t;
while(t--){
solve();
}
}