結果

問題 No.1465 Archaea
ユーザー tentententen
提出日時 2023-01-12 15:28:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 2,034 bytes
コンパイル時間 2,577 ms
コンパイル使用メモリ 92,352 KB
実行使用メモリ 58,916 KB
最終ジャッジ日時 2023-08-24 22:21:29
合計ジャッジ時間 5,622 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
49,372 KB
testcase_01 AC 41 ms
49,496 KB
testcase_02 AC 40 ms
49,504 KB
testcase_03 AC 42 ms
49,944 KB
testcase_04 AC 41 ms
49,448 KB
testcase_05 AC 41 ms
49,548 KB
testcase_06 AC 41 ms
49,344 KB
testcase_07 AC 46 ms
52,300 KB
testcase_08 AC 41 ms
49,564 KB
testcase_09 AC 47 ms
52,692 KB
testcase_10 AC 42 ms
49,732 KB
testcase_11 AC 49 ms
51,856 KB
testcase_12 AC 43 ms
49,404 KB
testcase_13 AC 56 ms
57,484 KB
testcase_14 AC 47 ms
53,128 KB
testcase_15 AC 42 ms
49,392 KB
testcase_16 AC 42 ms
49,996 KB
testcase_17 AC 59 ms
56,820 KB
testcase_18 AC 43 ms
50,332 KB
testcase_19 AC 54 ms
54,612 KB
testcase_20 AC 54 ms
55,768 KB
testcase_21 AC 63 ms
58,916 KB
testcase_22 AC 60 ms
57,712 KB
testcase_23 AC 43 ms
49,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    static int[] dp;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        dp = new int[n + 1];
        Arrays.fill(dp, -1);
        dp[1] = 0;
        int ans = dfw(n);
        if (ans <= k) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
    
    static int dfw(int x) {
        if (x <= 0) {
            return Integer.MAX_VALUE / 2;
        }
        if (dp[x] < 0) {
            dp[x] = dfw(x - 3) + 1;
            if (x % 2 == 0) {
                dp[x] = Math.min(dp[x], dfw(x / 2) + 1);
            }
        }
        return dp[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