Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- const int maxN = 1e5;
- int a[maxN];
- bool f (int k,int n) {
- for (int i = 1; i <= n; ++i) {
- if (a[i] - a[i - 1] > k) return false;
- if (a[i] - a[i - 1] == k) --k;
- }
- return true;
- }
- int main () {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- int T;
- cin >> T;
- for (int test_case = 1; test_case <= T; ++test_case) {
- int n;
- cin >> n;
- for (int i = 1; i <= n; ++i) cin >> a[i];
- a[0] = 0;
- int l = a[1],r = 1e8;
- int res = 0;
- while (l <= r) {
- int mid = (l + r) / 2;
- if (f(mid,n)) {
- res = mid;
- r = mid - 1;
- } else {
- l = mid + 1;
- }
- }
- cout << "Case " << test_case << ": " << res << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement