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
Task B - 高橋君と禁断の書
User uriku
Language Java (OpenJDK 1.7.0)
Score 0
Code Size 1588 Byte
Status
Exec Time 960 ms
Memory 36500 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 subtask0-sample-01.txt
All 0 / 100 subtask0-sample-01.txt, subtask1-01.txt, subtask1-02.txt, subtask1-03.txt, subtask1-04.txt, subtask1-05.txt, subtask1-06.txt, subtask1-07.txt, subtask1-08.txt, subtask1-09.txt, subtask1-10.txt, subtask1-11.txt, subtask1-12.txt, subtask1-13.txt, subtask1-14.txt, subtask1-15.txt, subtask1-16.txt, subtask1-17.txt, subtask1-18.txt, subtask1-19.txt, subtask1-20.txt, subtask1-21.txt, subtask1-22.txt, subtask1-23.txt, subtask1-24.txt, subtask1-25.txt, subtask1-26.txt, subtask1-27.txt, subtask1-28.txt, subtask1-29.txt, subtask1-30.txt
Case Name Status Exec Time Memory
subtask0-sample-01.txt 450 ms 23132 KB
subtask1-01.txt 451 ms 23180 KB
subtask1-02.txt 536 ms 24992 KB
subtask1-03.txt 707 ms 28852 KB
subtask1-04.txt 746 ms 31000 KB
subtask1-05.txt 815 ms 30308 KB
subtask1-06.txt 772 ms 32040 KB
subtask1-07.txt 769 ms 32728 KB
subtask1-08.txt 814 ms 32900 KB
subtask1-09.txt 774 ms 33064 KB
subtask1-10.txt 894 ms 36036 KB
subtask1-11.txt 960 ms 36068 KB
subtask1-12.txt 902 ms 36024 KB
subtask1-13.txt 844 ms 35088 KB
subtask1-14.txt 868 ms 35932 KB
subtask1-15.txt 892 ms 36356 KB
subtask1-16.txt 892 ms 35456 KB
subtask1-17.txt 893 ms 36052 KB
subtask1-18.txt 894 ms 35228 KB
subtask1-19.txt 872 ms 36004 KB
subtask1-20.txt 910 ms 36252 KB
subtask1-21.txt 877 ms 36044 KB
subtask1-22.txt 897 ms 35388 KB
subtask1-23.txt 881 ms 35152 KB
subtask1-24.txt 898 ms 36500 KB
subtask1-25.txt 880 ms 36256 KB
subtask1-26.txt 893 ms 36024 KB
subtask1-27.txt 871 ms 35808 KB
subtask1-28.txt 899 ms 35504 KB
subtask1-29.txt 892 ms 36168 KB
subtask1-30.txt 896 ms 36100 KB