結果

問題 No.1465 Archaea
ユーザー tentententen
提出日時 2021-04-13 12:40:04
言語 Java
(openjdk 23)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 1,371 bytes
コンパイル時間 3,335 ms
コンパイル使用メモリ 77,388 KB
実行使用メモリ 38,172 KB
最終ジャッジ日時 2024-06-29 13:29:20
合計ジャッジ時間 4,673 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] dp = new int[n + 1];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[n] = 0;
        for (int i = n; i > 1; i--) {
            if (dp[i] == Integer.MAX_VALUE) {
                continue;
            }
            if (i % 2 == 0) {
                dp[i / 2] = Math.min(dp[i / 2], dp[i] + 1);
            }
            if (i > 3) {
                dp[i - 3] = Math.min(dp[i - 3], dp[i] + 1);
            }
        }
        if (dp[1] <= k) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0