forked from csfx-py/hacktober2020
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoctorchef.cpp
More file actions
77 lines (64 loc) · 1.48 KB
/
doctorchef.cpp
File metadata and controls
77 lines (64 loc) · 1.48 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include<bits/stdc++.h>
#include<iostream>
#define lli long long int
#define ll long long
#define sq(a) (a)*(a)
#define endl "\n"
#define pb push_back
#define v vector
#define mp make_pair
#define boost ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define w() lli t; cin >> t; while(t--)
using namespace std;
int main() {
lli t;
cin >> t;
while (t--) {
lli n, x;
cin >> n >> x;
lli a[n];
for (lli &x : a) {
cin >> x;
}
int m;
sort(a, a + n);
// for (int i=0;i<n;i++){
// if(a[i]== n){
// cout<<n<<endl;
// return 0;
// }
// }
auto lower = lower_bound(a, a + n, x);
lli b[n];
lli i = 0;
for (int j = lower - a; j < n; ++j) {
b[i] = a[j];
i++;
}
for (int k = 0; k < lower - a; ++k) {
b[i] = a[k];
i++;
}
// for(auto x: b) {
// cout << x << " ";
// }
// cout<<"\n hello\n ";
int d = 0;
for (int i = 0; i < n; ++i) {
while (x < b[i]) {
d++;
b[i]=min(b[i],(b[i]-x)*2);
if(x>b[i])
x = x * 2;
}
if (x >= b[i]) {
d++;
x = b[i];
x = x * 2;
}
}
cout << d << endl;
// cout<<"Next tc\n";
}
return 0;
}