結果

問題 No.202 1円玉投げ
ユーザー fujisufujisu
提出日時 2015-05-09 17:02:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 929 ms / 5,000 ms
コード長 3,412 bytes
コンパイル時間 2,149 ms
コンパイル使用メモリ 75,388 KB
実行使用メモリ 72,980 KB
最終ジャッジ日時 2023-08-23 22:42:37
合計ジャッジ時間 20,859 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 707 ms
72,980 KB
testcase_01 AC 730 ms
71,732 KB
testcase_02 AC 47 ms
49,424 KB
testcase_03 AC 48 ms
49,040 KB
testcase_04 AC 47 ms
49,692 KB
testcase_05 AC 145 ms
58,068 KB
testcase_06 AC 751 ms
72,356 KB
testcase_07 AC 649 ms
64,428 KB
testcase_08 AC 655 ms
64,276 KB
testcase_09 AC 643 ms
72,192 KB
testcase_10 AC 325 ms
67,040 KB
testcase_11 AC 517 ms
68,324 KB
testcase_12 AC 605 ms
72,224 KB
testcase_13 AC 373 ms
67,828 KB
testcase_14 AC 158 ms
58,292 KB
testcase_15 AC 668 ms
71,956 KB
testcase_16 AC 744 ms
70,720 KB
testcase_17 AC 736 ms
71,276 KB
testcase_18 AC 703 ms
69,876 KB
testcase_19 AC 524 ms
69,928 KB
testcase_20 AC 594 ms
64,276 KB
testcase_21 AC 626 ms
70,984 KB
testcase_22 AC 114 ms
55,252 KB
testcase_23 AC 124 ms
55,172 KB
testcase_24 AC 85 ms
53,992 KB
testcase_25 AC 89 ms
53,680 KB
testcase_26 AC 118 ms
55,288 KB
testcase_27 AC 112 ms
55,344 KB
testcase_28 AC 93 ms
53,968 KB
testcase_29 AC 85 ms
54,292 KB
testcase_30 AC 92 ms
54,012 KB
testcase_31 AC 83 ms
53,708 KB
testcase_32 AC 89 ms
54,300 KB
testcase_33 AC 87 ms
54,212 KB
testcase_34 AC 96 ms
53,984 KB
testcase_35 AC 669 ms
71,096 KB
testcase_36 AC 700 ms
72,264 KB
testcase_37 AC 929 ms
72,220 KB
testcase_38 AC 711 ms
69,312 KB
testcase_39 AC 72 ms
52,152 KB
testcase_40 AC 63 ms
50,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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();

		ArrayList<Point>[] X = new ArrayList[20001];
		ArrayList<Point>[] Y = new ArrayList[20001];
		for (int i = 0; i < 20001; i++) {
			X[i] = new ArrayList<Point>();
			Y[i] = new ArrayList<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);

			int maxY = Math.min(20000, y + 19);
			for (int j = Math.max(0, y - 19); j <= maxY; j++) {
				for (Point q : Y[j]) {
					if (isIntersect(p, q)) {
						continue L;
					}
//					if (p.x < q.x && !isIntersect(p, q)) {
//						break;
//					}
				}
			}
			int maxX = Math.min(20000, x + 19);
			for (int j = Math.max(0, x - 19); j <= maxX; 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