-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVA-12032.cpp
More file actions
39 lines (32 loc) · 744 Bytes
/
UVA-12032.cpp
File metadata and controls
39 lines (32 loc) · 744 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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int t;
cin >> t;
for(int i = 1; i <= t; i++) {
cout << "Case " << i << ": ";
int n, k = 0;
cin >> n;
vector<ll> rungs;
rungs.push_back(0);
for(int j = 1; j <= n; j++){
ll temp;
cin >> temp;
rungs.push_back(temp);
}
for(int j = 1; j <= n; j++) {
if(rungs[j]-rungs[j-1] > k) k = rungs[j]-rungs[j-1];
}
int resp = k;
for(int j = 1; j <= n; j++) {
if(rungs[j]-rungs[j-1] == k) k--;
else if(rungs[j]-rungs[j-1] > k) {
resp++;
break;
}
}
cout << resp << endl;
}
return 0;
}