結果

問題 No.202 1円玉投げ
ユーザー fujisufujisu
提出日時 2015-05-09 05:17:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 2,335 ms / 5,000 ms
コード長 3,311 bytes
コンパイル時間 2,748 ms
コンパイル使用メモリ 80,172 KB
実行使用メモリ 86,736 KB
最終ジャッジ日時 2024-12-22 08:47:02
合計ジャッジ時間 34,601 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,616 ms
85,996 KB
testcase_01 AC 1,396 ms
79,492 KB
testcase_02 AC 60 ms
52,108 KB
testcase_03 AC 61 ms
52,360 KB
testcase_04 AC 61 ms
52,328 KB
testcase_05 AC 174 ms
60,024 KB
testcase_06 AC 1,113 ms
77,608 KB
testcase_07 AC 1,190 ms
78,952 KB
testcase_08 AC 1,148 ms
80,940 KB
testcase_09 AC 896 ms
75,796 KB
testcase_10 AC 427 ms
72,012 KB
testcase_11 AC 832 ms
75,544 KB
testcase_12 AC 805 ms
75,292 KB
testcase_13 AC 447 ms
73,344 KB
testcase_14 AC 236 ms
61,668 KB
testcase_15 AC 960 ms
75,544 KB
testcase_16 AC 1,844 ms
86,520 KB
testcase_17 AC 1,980 ms
86,580 KB
testcase_18 AC 1,930 ms
80,444 KB
testcase_19 AC 514 ms
67,548 KB
testcase_20 AC 1,110 ms
78,952 KB
testcase_21 AC 702 ms
75,664 KB
testcase_22 AC 156 ms
58,532 KB
testcase_23 AC 151 ms
57,952 KB
testcase_24 AC 106 ms
54,076 KB
testcase_25 AC 111 ms
56,336 KB
testcase_26 AC 151 ms
59,756 KB
testcase_27 AC 150 ms
58,356 KB
testcase_28 AC 117 ms
56,456 KB
testcase_29 AC 109 ms
56,472 KB
testcase_30 AC 111 ms
56,272 KB
testcase_31 AC 105 ms
53,640 KB
testcase_32 AC 121 ms
56,532 KB
testcase_33 AC 118 ms
56,128 KB
testcase_34 AC 134 ms
57,236 KB
testcase_35 AC 2,270 ms
82,632 KB
testcase_36 AC 1,914 ms
73,544 KB
testcase_37 AC 1,359 ms
83,496 KB
testcase_38 AC 2,335 ms
86,736 KB
testcase_39 AC 96 ms
53,648 KB
testcase_40 AC 88 ms
53,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	class Point implements Comparable<Point> {
		int x, y;

		Point(int x, int y) {
			this.x = x;
			this.y = y;
		}

		@Override
		public int compareTo(Point o) {
			return this.x != o.x ? this.x - o.x : this.y - o.y;
		}
	}

	boolean isIntersect(Point a, Point b) {
		return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) < 400;
	}

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

		TreeSet<Point>[] X = new TreeSet[20001];
		TreeSet<Point>[] Y = new TreeSet[20001];
		for (int i = 0; i < 20001; i++) {
			X[i] = new TreeSet<Point>();
			Y[i] = new TreeSet<Point>();
		}

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

			for (int j = Math.max(0, x - 20); j <= Math.min(20000, x + 20); j++) {
				for (Point q : X[j]) {
					if (isIntersect(p, q)) {
						continue L;
					}
					if (20 < q.x - p.x) {
						break;
					}
				}
			}
			for (int j = Math.max(0, y - 10); j <= Math.min(20000, y + 20); j++) {
				for (Point q : Y[j]) {
					if (isIntersect(p, q)) {
						continue L;
					}
					if (20 < q.y - p.y) {
						break;
					}
				}
			}
			X[x].add(p);
			Y[y].add(p);
			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