結果

問題 No.1465 Archaea
ユーザー tentententen
提出日時 2023-03-23 19:08:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 2,092 bytes
コンパイル時間 4,244 ms
コンパイル使用メモリ 84,188 KB
実行使用メモリ 56,172 KB
最終ジャッジ日時 2023-10-18 19:36:18
合計ジャッジ時間 8,094 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
51,528 KB
testcase_01 AC 49 ms
36,684 KB
testcase_02 AC 50 ms
36,704 KB
testcase_03 AC 49 ms
36,708 KB
testcase_04 AC 49 ms
36,700 KB
testcase_05 AC 51 ms
36,716 KB
testcase_06 AC 49 ms
36,688 KB
testcase_07 AC 92 ms
41,248 KB
testcase_08 AC 50 ms
36,712 KB
testcase_09 AC 96 ms
42,552 KB
testcase_10 AC 50 ms
36,712 KB
testcase_11 AC 104 ms
43,964 KB
testcase_12 AC 52 ms
36,816 KB
testcase_13 AC 128 ms
52,120 KB
testcase_14 AC 91 ms
41,388 KB
testcase_15 AC 50 ms
36,764 KB
testcase_16 AC 54 ms
36,812 KB
testcase_17 AC 130 ms
52,568 KB
testcase_18 AC 61 ms
37,536 KB
testcase_19 AC 109 ms
46,764 KB
testcase_20 AC 106 ms
45,788 KB
testcase_21 AC 142 ms
55,704 KB
testcase_22 AC 152 ms
56,172 KB
testcase_23 AC 50 ms
36,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    static HashMap<Integer, Integer> dp = new HashMap<>();
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        dp.put(1, 0);
        if (dfw(n) > k) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }
    }
    
    static int dfw(int x) {
        if (x <= 0) {
            return Integer.MAX_VALUE / 2;
        }
        if (!dp.containsKey(x)) {
            int ans = Integer.MAX_VALUE / 2;
            if (x % 2 == 0) {
                ans = Math.min(ans, dfw(x / 2) + 1);
            }
            ans = Math.min(ans, dfw(x - 3) + 1);
            dp.put(x, ans);
        }
        return dp.get(x);
    }
    
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0