File tree 1 file changed +55
-0
lines changed
1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change
1
+ // ॐ नमः शिवाय
2
+ #include < bits/stdc++.h>
3
+ using namespace std ;
4
+
5
+ #define ll long long
6
+ #define pb push_back
7
+ #define ff first
8
+ #define ss second
9
+ #define mp make_pair
10
+
11
+ // Code Written By: Vikash Patel
12
+ // Codeforces Profile: https://codeforces.com/profile/vikashpatel
13
+
14
+ int solve (int a[], int n)
15
+ {
16
+ int c = 0 ;
17
+ for (int i=1 ; i<n; i++)
18
+ {
19
+ int maxi = max (a[i], a[i-1 ]);
20
+ int mini = min (a[i], a[i-1 ]);
21
+ while (maxi > 2 *mini)
22
+ {
23
+ c++;
24
+ mini = mini*2 ;
25
+ }
26
+ }
27
+ return c;
28
+ }
29
+
30
+ int main ()
31
+ {
32
+ ios_base::sync_with_stdio (0 );
33
+ cin.tie (0 );
34
+ cout.tie (0 );
35
+
36
+ // #ifndef ONLINE_JUDGE
37
+ // freopen("input.txt", "r", stdin);
38
+ // freopen("/Users/vikash/Desktop/output.txt", "w", stdout);
39
+ // #endif
40
+
41
+ int t;
42
+ cin>>t;
43
+ while (t--)
44
+ {
45
+ int n;
46
+ cin>>n;
47
+ int a[n];
48
+ for (int i=0 ; i<n; i++)
49
+ {
50
+ cin>>a[i];
51
+ }
52
+ cout<<solve (a, n)<<endl;
53
+ }
54
+ return 0 ;
55
+ }
You can’t perform that action at this time.
0 commit comments