forked from Mohammed-Shoaib/Coding-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathE0064.cpp
More file actions
40 lines (35 loc) · 667 Bytes
/
E0064.cpp
File metadata and controls
40 lines (35 loc) · 667 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
// Problem Code: PLAYFIT
#include <iostream>
#include <string>
#include <vector>
#include <limits>
using namespace std;
string fitToPlay(vector<int> g) {
int min, diff;
min = g[0];
diff = numeric_limits<int>::min();
for (int i = 1 ; i < g.size() ; i++) {
if (diff < g[i] - min)
diff = g[i] - min;
if (min > g[i])
min = g[i];
}
return (diff <= 0) ? "UNFIT" : to_string(diff);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int T, N, num;
vector<int> g;
cin >> T;
while (T--) {
cin >> N;
for (int i = 0 ; i < N ; i++) {
cin >> num;
g.push_back(num);
}
cout << fitToPlay(g) << endl;
g.clear();
}
return 0;
}