-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1675B.cpp
More file actions
43 lines (31 loc) · 773 Bytes
/
1675B.cpp
File metadata and controls
43 lines (31 loc) · 773 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
#include <bits/stdc++.h>
using namespace std;
#define fast_io ios::sync_with_stdio(false); cin.tie(nullptr);
int main() {
fast_io;
int t;
cin >> t;
while (t--) {
// solve here
long long n;
cin >> n;
vector<long long> a(n);
for (int i = 0 ; i < n; i++)
cin >> a[i];
long long ans = 0;
for (int i = n - 2; i >= 0; i--){
while (a[i] >= a[i + 1]){
ans++;
a[i] /= 2;
if (a[i] == 0)
break;
}
if (a[i] == 0 && a[i + 1] == 0 ){
ans = -1;
break;
}
}
cout << ans << endl;
}
return 0;
}