forked from csfx-py/hacktober2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocchf.cpp
64 lines (55 loc) · 1.05 KB
/
docchf.cpp
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
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define boost ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
int fun(int g)
{
return(2*g);
}
int main(){
/*
int n;//input size
cin >> n;
int l=1;
vector<int>a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
a.erase (a.begin() + l);
for (auto x : a) {
cout << x << " ";
}
*/
ll t;
cin>>t;
while(t-->0)
{
ll n,x;
cin>>n>>x;
vector<ll>a(n);
ll day = 0;
ll h = 0;
for(int i=0;i<n;i++)
{
cin >> a[i];
}
sort(a.begin(), a.end());
while(!a.empty())
{
day++;
if(a[h] <= x)
{
a.erase(a.begin());
h++;
x=fun(x);
}else if(a[h]>x){
a[h]=min(a[h],(a[h]-x)*2);
if(x>a[h])
x=fun(x);
}
}
cout << day <<endl;
}
return 0;
}