結果
| 問題 |
No.1465 Archaea
|
| コンテスト | |
| ユーザー |
martins
|
| 提出日時 | 2021-04-28 11:37:02 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 149 ms / 2,000 ms |
| コード長 | 638 bytes |
| コンパイル時間 | 3,540 ms |
| コンパイル使用メモリ | 76,400 KB |
| 実行使用メモリ | 57,004 KB |
| 最終ジャッジ日時 | 2024-07-07 05:52:16 |
| 合計ジャッジ時間 | 8,538 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
int[] dist = new int[n+1];
Arrays.fill(dist, -1);
LinkedList<Integer> q = new LinkedList<>();
q.add(1);
dist[1] = 0;
while(!q.isEmpty()) {
int u = q.remove();
int a = 2 * u;
if(a <= n && dist[a] < 0) {
dist[a] = dist[u]+1;
q.add(a);
}
int b = u + 3;
if(b <= n && dist[b] < 0) {
dist[b] = dist[u] + 1;
q.add(b);
}
}
if(dist[n] >= 0 && dist[n] <= k) System.out.println("YES");
else System.out.println("NO");
}
}
martins