結果

問題 No.202 1円玉投げ
ユーザー fujisufujisu
提出日時 2015-05-09 05:50:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 3,153 ms / 5,000 ms
コード長 2,898 bytes
コンパイル時間 3,075 ms
コンパイル使用メモリ 79,052 KB
実行使用メモリ 78,032 KB
最終ジャッジ日時 2023-11-26 14:55:46
合計ジャッジ時間 28,507 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,508 ms
67,176 KB
testcase_01 AC 2,375 ms
67,224 KB
testcase_02 AC 54 ms
53,720 KB
testcase_03 AC 54 ms
53,856 KB
testcase_04 AC 55 ms
53,860 KB
testcase_05 AC 302 ms
63,068 KB
testcase_06 AC 2,319 ms
67,256 KB
testcase_07 AC 2,874 ms
75,292 KB
testcase_08 AC 2,707 ms
75,504 KB
testcase_09 AC 1,422 ms
65,172 KB
testcase_10 AC 823 ms
71,524 KB
testcase_11 AC 1,288 ms
73,560 KB
testcase_12 AC 1,219 ms
65,212 KB
testcase_13 AC 1,032 ms
71,048 KB
testcase_14 AC 308 ms
63,080 KB
testcase_15 AC 1,515 ms
73,252 KB
testcase_16 AC 1,031 ms
67,216 KB
testcase_17 AC 1,445 ms
67,344 KB
testcase_18 AC 1,250 ms
67,368 KB
testcase_19 AC 1,286 ms
65,192 KB
testcase_20 AC 2,611 ms
78,032 KB
testcase_21 AC 1,245 ms
65,172 KB
testcase_22 AC 124 ms
56,420 KB
testcase_23 AC 137 ms
59,156 KB
testcase_24 AC 129 ms
58,616 KB
testcase_25 AC 124 ms
59,364 KB
testcase_26 AC 142 ms
59,444 KB
testcase_27 AC 123 ms
59,068 KB
testcase_28 AC 136 ms
59,232 KB
testcase_29 AC 150 ms
59,096 KB
testcase_30 AC 136 ms
59,264 KB
testcase_31 AC 133 ms
59,652 KB
testcase_32 AC 154 ms
59,164 KB
testcase_33 AC 146 ms
59,144 KB
testcase_34 AC 156 ms
59,432 KB
testcase_35 AC 1,724 ms
77,916 KB
testcase_36 AC 1,367 ms
68,064 KB
testcase_37 AC 3,153 ms
75,356 KB
testcase_38 AC 1,454 ms
67,460 KB
testcase_39 AC 110 ms
56,296 KB
testcase_40 AC 105 ms
55,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.util.HashSet;
import java.util.InputMismatchException;

public class Main {
	boolean isIntersect(int x, int y, int a, int b) {
		return (x - a) * (x - a) + (y - b) * (y - b) < 400;
	}

	void run() {
		MyScanner sc = new MyScanner();

		HashSet<Integer>[] set = new HashSet[20001];
		for (int i = 0; i < 20001; i++) {
			set[i] = new HashSet<Integer>();
		}

		int n = sc.nextInt();

		int ans = 0;
		L: for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();

			int minX = Math.max(0, x - 20);
			int minY = Math.max(0, y - 20);
			int maxX = Math.min(20000, x + 20);
			int maxY = Math.min(20000, y + 20);
			for (int j = minX; j <= maxX; j++) {
				for (int k = minY; k <= maxY; k++) {
					if (!set[j].contains(k)) {
						continue;
					}
					if (isIntersect(x, y, j, k)) {
						continue L;
					}
				}
			}
			set[x].add(y);
			ans++;
		}
		System.out.println(ans);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}
0