-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathQ1.java
More file actions
33 lines (31 loc) · 767 Bytes
/
Copy pathQ1.java
File metadata and controls
33 lines (31 loc) · 767 Bytes
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
package microsoft;
import java.util.*;
public class Q1 {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
int TASKS = in.nextInt();
for (int t = 0; t < TASKS; t++) {
int N = in.nextInt();
int P = in.nextInt();
int W = in.nextInt();
int H = in.nextInt();
int[] num = new int[N];
for (int i = 0; i < N; i++)
num[i] = in.nextInt();
int max = 1;
for (int size = 2; size <= Math.min(W, H); size++) {
int col = W/size;
int row = H/size;
int total = 0;
for (int i = 0; i < N; i++) {
total += (int) Math.ceil((double) num[i] / (double) col);
}
if (P * row >= total)
max = size;
}
System.out.println(max);
}
}
}
}