-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathDrCheff.cpp
51 lines (50 loc) · 1023 Bytes
/
DrCheff.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
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
long long int n,x,i,day=0,c=0,cured,first,infected,left;
cin>>n>>x;
long long int a[n];
for(i=0; i<n; i++)
cin>>a[i];
sort(a,a+n);
for(i=0; i<n; i++)
{
if(x<=a[i])
{
first=a[i];
break;
}
c++;
}
cured=x;
while(i<n)
{
first=a[i];
while(cured<first)
{
left=first-cured;
infected=2*left;
if(infected>first)
{
infected=first;
cured=2*cured;
}
else
{
cured=infected;
}
day++;
}
day++;
cured=2*first;
i++;
}
cout<<c+day;
}
return 0;
}