-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patholliePS-118.cpp
53 lines (52 loc) · 1.13 KB
/
olliePS-118.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
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define flash() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
flash();
ll t;
cin >> t;
for(ll i = 1 ; i<=t ; i++)
{
ll n , h;
cin >> n >> h;
vector<ll> v(n);
for(ll j = 0 ; j < n ; j++)
{
cin >> v[j];
}
vector<ll> :: iterator it;
it = max_element(v.begin() , v.end());
ll me = *it , nme;
if(it == v.end()-1)
{
nme = *max_element(v.begin() , it);
}
else if(it == v.begin())
{
nme = *max_element(it+1 , v.end());
}
else
{
nme = max(*max_element(v.begin() , it) , *max_element(it+1 , v.end()));
}
ll s = me + nme;
if( h % s == 0 )
{
cout << 2*(h/s) << endl;
}
else
{
if( h % s <= me)
{
cout << 2*(h/s) + 1 << endl;
}
else
{
cout << 2*(h/s) + 2 << endl;
}
}
}
return 0;
}