Contest Duration: ~ (local time) (90 minutes) Back to Home

Submission #242278

Source Code Expand

Copy
```import java.util.Scanner;

public class Main {

static int a, b, n;
static int[] c, d;

static boolean canBoxTate(int i) {
if (c[i] >= a && d[i] >= b) {
return true;
}
return false;
}

static boolean canBoxYoko(int i) {
if (c[i] >= b && d[i] >= a) {
return true;
}
return false;
}

static boolean canBoxNaname(int i) {
double x = Math.sqrt(a * a / 2.0);
double y = Math.sqrt(b * b / 2.0);

if (x + y <= Math.min(c[i], d[i])) {
return true;
}

return false;
}

static boolean canBoxNaname2(int i) {
int am = Math.max(a, b);
int bm = Math.min(a, b);
int cm = Math.max(c[i], d[i]);
int dm = Math.min(c[i], d[i]);

double x = Math.sqrt(bm * bm / (1 + bm / cm));
double y = x * dm / cm;

double q = Math.sqrt(am * am / (1 + bm / cm));
double p = q * dm /cm;

if (q + y >= cm && p + x >= dm) {
return true;
}

return false;
}

public static void main(String[] args) {
Scanner scan = new Scanner(System.in);

a = scan.nextInt();
b = scan.nextInt();
n = scan.nextInt();
c = new int[n];
d = new int[n];

for (int i = 0; i < n; i++) {
c[i] = scan.nextInt();
d[i] = scan.nextInt();
}

for (int i = 0; i < n; i++) {
if (canBoxTate(i)) {
System.out.println("YES");
continue;
}

if (canBoxYoko(i)) {
System.out.println("YES");
continue;
}

if (canBoxNaname2(i)) {
System.out.println("YES");
continue;
}
System.out.println("NO");
}

scan.close();
}

}
```

#### Submission Info

Submission Time 2014-09-27 22:25:53+0900 B - 高橋君と禁断の書 uriku Java (OpenJDK 1.7.0) 0 1588 Byte WA 960 ms 36500 KB

#### Test Cases

Set Name Score / Max Score Test Cases
Case Name Status Exec Time Memory