hiho week 148 register

Ended

Participants:382

Verdict:Wrong Answer
Score:0 / 100
Submitted:2017-05-05 13:51:16

Lang:Java

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
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int TASKS= in.nextInt();
        for (int task = 1task <=TASKStask++) {
            int N = in.nextInt();
            int P = in.nextInt();
            int W = in.nextInt();
            int H = in.nextInt();
            int[] a=new int[N];
            for(int i=0;i<N;i++){
                a[i]=in.nextInt();
            }
            int min=1,max=Math.min(WH),curs=(min+max)/2,totalP,s=0;
            int wordsPerRow,rowsPerPage;
            while(true){
                if(curs==s)break;
                wordsPerRow=W/curs;
                rowsPerPage=H/curs;
                totalP=0;
                for(int i=0;i<N;i++){
                    totalP=totalP+(int)Math.ceil((double)a[i]/wordsPerRow);
                }
                totalP=(int)Math.ceil((double)totalP/rowsPerPage);
                if(totalP<=P){
                    s=curs;
                    if(curs==max)break;
                    else if(max-curs==1){
                        curs=max;
                    }else{
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX