結果
問題 | No.202 1円玉投げ |
ユーザー |
![]() |
提出日時 | 2021-01-20 12:02:17 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 1,339 ms / 5,000 ms |
コード長 | 1,259 bytes |
コンパイル時間 | 2,922 ms |
コンパイル使用メモリ | 77,680 KB |
実行使用メモリ | 61,168 KB |
最終ジャッジ日時 | 2024-12-22 12:06:34 |
合計ジャッジ時間 | 33,050 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
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;}}}