hiho week 148 register

Ended

Participants:382

Verdict:Accepted
Score:100 / 100
Submitted:2017-05-02 21:58:45

Lang:G++

Edit
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
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a[1111];
int n,w,p,h;
bool isok(int x){
    int sz=(w/x);
    int num=0;
    for(int i=1;i<=n;i++){
        num+=(a[i]+sz-1)/sz;
    }
    return num<=p*(h/x);
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--){
        scanf("%d%d%d%d",&n,&p,&w,&h);
        for(int i=1;i<=n;i++)scanf("%d",&a[i]);
        int l=1,r=min(w,h);
        int ans;
        while(l<=r){
            int mid=l+r>>1;
            if(isok(mid)){
                l=mid+1;
                ans=mid;
            }
            else r=mid-1;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX