-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphonedesk.java
More file actions
32 lines (24 loc) · 893 Bytes
/
Copy pathphonedesk.java
File metadata and controls
32 lines (24 loc) · 893 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
package RandomCF;
import java.util.Scanner;
public class phonedesk {
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
int testcases = inp.nextInt();
for(int i = 0; i<testcases; i++){
int x = inp.nextInt();
int y = inp.nextInt();
System.out.println(screen(x,y));
}
}
public static int screen(int x, int y){
int screensFor2x2 = (y + 1) / 2; // Each screen can hold up to 2 2x2 icons
int remainingCells = (screensFor2x2 * 15) - (y * 4);
int remaining1x1Icons = x - remainingCells;
if (remaining1x1Icons <= 0) {
return screensFor2x2;
} else {
int screensFor1x1 = (remaining1x1Icons + 14) / 15; // Each screen can hold 15 1x1 icons
return screensFor2x2 + screensFor1x1;
}
}
}