-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPLAYFIT.cpp
More file actions
65 lines (61 loc) · 1011 Bytes
/
PLAYFIT.cpp
File metadata and controls
65 lines (61 loc) · 1011 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <climits>
#include <queue>
#define ll long long
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin>>t;
while(t--){
int n;
cin>>n;
bool baseCond=false;
vector<int> v;
int x,prev;
cin>>x;
prev=x;
v.push_back(x);
for(int i = 1; i < n ; i++){
cin>>x;
if(x>prev){
baseCond=true;
}
prev=x;
v.push_back(x);
}
if(baseCond){
int ans = INT_MIN,min=v[0];
for(int i=1;i<n;i++){
if(min>v[i]){
min=v[i];
}
else
ans=max(v[i]-min,ans);
}
if(ans==INT_MIN){
cout<<"UNFIT\n";
}
else{
cout<<ans<<endl;
}
}
else{
cout<<"UNFIT\n";
}
}
return 0;
}