結果
| 問題 |
No.202 1円玉投げ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-06-08 14:13:18 |
| 言語 | Java (openjdk 23) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 2,242 bytes |
| コンパイル時間 | 3,045 ms |
| コンパイル使用メモリ | 88,468 KB |
| 実行使用メモリ | 1,225,012 KB |
| 最終ジャッジ日時 | 2024-12-22 10:25:41 |
| 合計ジャッジ時間 | 168,345 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 MLE * 1 |
| other | AC * 13 TLE * 6 MLE * 19 |
ソースコード
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
public class Main {
private static Set<int[]> leftOfCoin = new TreeSet<int[]>(new IntArrayComparator());
/* 座標(0,0)から距離20未満の座標の一覧 */
private static final List<int[]> DISTANCE_UNDER_20_POINT_LIST = new ArrayList<int[]>();
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int limit = cin.nextInt();
int leftCount = 0;
for (int i = -19; i <= 19; i++) {
for (int j = -19; j <= 19; j++) {
if (i * i + j * j < 400) {
DISTANCE_UNDER_20_POINT_LIST.add(new int[] {i, j});
}
}
}
int[] point = new int[2];
for (int i = 0; i < limit; i++) {
point[0] = cin.nextInt();
point[1] = cin.nextInt();
if (isLeft(point)) {
leftCount++;
}
}
System.out.println(leftCount);
}
private static boolean isLeft(int[] point) {
if (leftOfCoin.contains(point)) {
/* コインが置けない場所としてマークされていたらfalseを返す */
return false;
}
/* コインが置ける場所であれば、そのコインが置かれたことにより、コインを置くことができなくなるポイントをチェックする。コインが置けなくなるポイント=今置いた場所から距離20(2円の半径の和)未満である場所。(=の時は外接なのでセーフ) */
DISTANCE_UNDER_20_POINT_LIST.forEach(coins -> {
if (point[0] + coins[0] >= 0 && point[0] + coins[0] <= 20000 && point[1] + coins[1] >= 0 && point[1] + coins[1] <= 20000) {
leftOfCoin.add(new int[] {point[0] + coins[0], point[1] + coins[1]});
}
});
return true;
}
static class IntArrayComparator implements Comparator<int[]> {
@Override
public int compare(int[] o1, int[] o2) {
return o1[0] == o2[0] ? o1[1] == o2[1] ? 0 : o1[1] - o2[1] : o1[0] - o2[0];
}
}
}