hiho week 148 register

Ended

Participants:382

Verdict:Accepted
Score:100 / 100
Submitted:2017-05-01 17:49:50

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
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
int a[maxn];
int main()
{
    int T;scanf("%d",&T);
    while(T--){
        int n,p,w,h;
        scanf("%d%d%d%d",&n,&p,&w,&h);
        for( int i = 0; i < n; i++ )scanf("%d",a+i);
        int ans;
        int mn = min(h,w);
        for( int i = 1; i <= mn; i++ ){
            int sum = 0;
            int col = w / i,row = h / i;
            for( int j = 0; j < n; j++ ){
                sum += (a[j] - 1) / col + 1;
            }
            if((sum - 1) / row + 1 > p){
                break;
            }
            else ans = i;
        }
        printf("%d\n",ans);
    }
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX