結果

問題 No.202 1円玉投げ
ユーザー tentententen
提出日時 2021-01-20 12:02:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,010 ms / 5,000 ms
コード長 1,259 bytes
コンパイル時間 2,406 ms
コンパイル使用メモリ 75,080 KB
実行使用メモリ 71,928 KB
最終ジャッジ日時 2023-08-24 00:18:25
合計ジャッジ時間 25,085 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 965 ms
70,020 KB
testcase_01 AC 902 ms
70,192 KB
testcase_02 AC 115 ms
56,280 KB
testcase_03 AC 120 ms
55,836 KB
testcase_04 AC 115 ms
55,816 KB
testcase_05 AC 279 ms
60,600 KB
testcase_06 AC 819 ms
70,644 KB
testcase_07 AC 850 ms
70,164 KB
testcase_08 AC 853 ms
71,508 KB
testcase_09 AC 658 ms
70,464 KB
testcase_10 AC 416 ms
61,504 KB
testcase_11 AC 579 ms
69,584 KB
testcase_12 AC 597 ms
69,096 KB
testcase_13 AC 435 ms
62,788 KB
testcase_14 AC 290 ms
61,272 KB
testcase_15 AC 616 ms
69,312 KB
testcase_16 AC 919 ms
67,072 KB
testcase_17 AC 936 ms
68,936 KB
testcase_18 AC 928 ms
69,256 KB
testcase_19 AC 618 ms
69,628 KB
testcase_20 AC 864 ms
71,396 KB
testcase_21 AC 637 ms
70,208 KB
testcase_22 AC 190 ms
58,176 KB
testcase_23 AC 196 ms
58,300 KB
testcase_24 AC 189 ms
58,088 KB
testcase_25 AC 194 ms
58,348 KB
testcase_26 AC 191 ms
58,688 KB
testcase_27 AC 190 ms
58,508 KB
testcase_28 AC 190 ms
56,676 KB
testcase_29 AC 194 ms
58,660 KB
testcase_30 AC 194 ms
58,388 KB
testcase_31 AC 188 ms
58,208 KB
testcase_32 AC 188 ms
58,288 KB
testcase_33 AC 204 ms
59,080 KB
testcase_34 AC 205 ms
59,644 KB
testcase_35 AC 989 ms
69,176 KB
testcase_36 AC 1,001 ms
70,088 KB
testcase_37 AC 978 ms
71,928 KB
testcase_38 AC 1,010 ms
69,216 KB
testcase_39 AC 167 ms
55,988 KB
testcase_40 AC 163 ms
56,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int w = 101;
		int h = 101;
		ArrayList<ArrayList<Point>> field = new ArrayList<>();
		for (int i = 0; i < w * h; i++) {
		    field.add(new ArrayList<>());
		}
		int count = 0;
		for (int i = 0; i < n; i++) {
		    Point p = new Point(sc.nextInt(), sc.nextInt());
		    int x = p.x / 200;
		    int y = p.y / 200;
		    boolean canSet = true;
		    for (int j = Math.max(0, x - 1); j <= Math.min(100, x + 1) && canSet; j++) {
		        for (int k = Math.max(0, y - 1); k <= Math.min(100, y + 1) && canSet; k++) {
		            for (Point z : field.get(j * w + k)) {
		                canSet = z.diff(p);
		                if (!canSet) {
		                    break;
		                }
		            }
		        }
		    }
		    if (canSet) {
		        field.get(x * w + y).add(p);
		        count++;
		    }
		}
		System.out.println(count);
	}
	
	static class Point {
	    int x;
	    int y;
	    
	    public Point(int x, int y) {
	        this.x = x;
	        this.y = y;
	    }
	    
	    public boolean diff(Point p) {
	        return (x - p.x) * (x - p.x) + (y - p.y) * (y - p.y) >= 20 * 20;
	    }
	}
}
0