-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVA 12032.cpp
More file actions
48 lines (35 loc) · 726 Bytes
/
UVA 12032.cpp
File metadata and controls
48 lines (35 loc) · 726 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
#include <bits/stdc++.h>
using namespace std;
const int N=100001;
int n;
int arr[N];
bool able(int k){
for(int i=1; i<=n; i++){
if(arr[i]-arr[i-1]>k) return false;
if(arr[i]-arr[i-1]==k) k = k-1;
}
return true;
}
int main() {
//freopen("input.txt","r",stdin);
int t;
cin>>t;
for(int i=1; i<=t; i++){
cin>>n;
for(int j=1; j<=n; j++){
cin>>arr[j];
}
arr[0] = 0;
int low = 1;
int high = 10000000;
while(high-low>1){
int mid = (low+high)/2;
if(able(mid)){
high = mid;
}
else low = mid+1;
}
if(able(low)) cout<<"Case "<<i<<": "<<low<<endl;
else if(able(high)) cout<<"Case "<<i<<": "<<high<<endl;
}
}