Repository navigation
Expand file tree
/
Copy pathbanna.cpp
More file actions
64 lines (64 loc) · 1.58 KB
/
Copy pathbanna.cpp
File metadata and controls
64 lines (64 loc) · 1.58 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
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define Fl(i,a,b) for(ll i=a;i<b;i++)
#define Fll(i,a,b) for(ll i=a;i<=b;i++)
#define Fr(i,a,b) for(ll i=a;i>=0;i--)
//-------------------------------------------------------
#define ipair pair<ll,ll>
#define vll vector<ll>
#define vstr vector<string>
#define vchar vector<char>
#define sll set<ll>
#define mll map<ll,ll>
//---------------------------------------------------------
#define MIN -1
#define MAX 1e10
#define VER 101
#define fastread ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
vll adj[VER];
//----------------------------------------------------------------------------
void make_edge(ll a,ll b)
{
adj[a].pb(b);
adj[b].pb(a);
}
//-----------------------------------------------------------------------------
int main()
{
ll t,n,h,hour,top,bottom,mid,ans=MAX;
cin>>t;
while(t--){
ans=-1;
cin>>n>>h;
vll pile(n);
Fl(i,0,n)
cin>>pile[i];
sort(all(pile));
top=pile[n-1];
bottom=1;
while(bottom<=top){
mid=(top+bottom)/2;
hour=0;
Fl(i,0,n){
if(mid<pile[i])
hour+=(pile[i]/mid+(pile[i]%mid!=0));
else
hour++;
}
//cout<<hour<<" ";
if(hour>h)
bottom=mid+1;
else{
ans=mid;
top=mid-1;
}
}
cout<<ans<<"\n";
}
return 0;
}