結果

問題 No.202 1円玉投げ
ユーザー fujisufujisu
提出日時 2015-05-09 06:42:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,548 ms / 5,000 ms
コード長 3,346 bytes
コンパイル時間 2,288 ms
コンパイル使用メモリ 79,896 KB
実行使用メモリ 86,468 KB
最終ジャッジ日時 2024-06-01 20:07:08
合計ジャッジ時間 28,192 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,081 ms
85,624 KB
testcase_01 AC 1,548 ms
75,964 KB
testcase_02 AC 59 ms
52,104 KB
testcase_03 AC 58 ms
52,352 KB
testcase_04 AC 57 ms
52,396 KB
testcase_05 AC 173 ms
57,936 KB
testcase_06 AC 1,157 ms
83,340 KB
testcase_07 AC 991 ms
75,692 KB
testcase_08 AC 1,177 ms
83,692 KB
testcase_09 AC 824 ms
75,596 KB
testcase_10 AC 426 ms
71,640 KB
testcase_11 AC 843 ms
75,612 KB
testcase_12 AC 797 ms
75,568 KB
testcase_13 AC 378 ms
64,584 KB
testcase_14 AC 187 ms
61,340 KB
testcase_15 AC 842 ms
75,712 KB
testcase_16 AC 1,408 ms
86,468 KB
testcase_17 AC 1,339 ms
79,732 KB
testcase_18 AC 1,480 ms
86,308 KB
testcase_19 AC 843 ms
75,428 KB
testcase_20 AC 1,080 ms
76,188 KB
testcase_21 AC 808 ms
75,448 KB
testcase_22 AC 152 ms
58,576 KB
testcase_23 AC 120 ms
57,276 KB
testcase_24 AC 110 ms
56,440 KB
testcase_25 AC 102 ms
56,544 KB
testcase_26 AC 149 ms
58,916 KB
testcase_27 AC 122 ms
56,988 KB
testcase_28 AC 99 ms
53,532 KB
testcase_29 AC 104 ms
56,664 KB
testcase_30 AC 105 ms
56,192 KB
testcase_31 AC 92 ms
53,828 KB
testcase_32 AC 111 ms
56,476 KB
testcase_33 AC 101 ms
56,264 KB
testcase_34 AC 117 ms
56,848 KB
testcase_35 AC 1,482 ms
80,656 KB
testcase_36 AC 626 ms
82,332 KB
testcase_37 AC 891 ms
72,576 KB
testcase_38 AC 1,495 ms
82,236 KB
testcase_39 AC 91 ms
53,548 KB
testcase_40 AC 87 ms
53,504 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, y - 19); j <= Math.min(20000, y + 19); j++) {
				for (Point q : Y[j]) {
					if (isIntersect(p, q)) {
						continue L;
					}
					if (p.x < q.x && !isIntersect(p, q)) {
						break;
					}
				}
			}
			for (int j = Math.max(0, x - 19); j <= Math.min(20000, x + 19); j++) {
				for (Point q : X[j]) {
					if (isIntersect(p, q)) {
						continue L;
					}
					if (p.y < q.y && !isIntersect(p, q)) {
						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