結果

問題 No.1465 Archaea
ユーザー Manuel1024Manuel1024
提出日時 2021-05-04 01:53:39
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 626 bytes
コンパイル時間 552 ms
コンパイル使用メモリ 68,176 KB
実行使用メモリ 4,396 KB
最終ジャッジ日時 2023-09-29 21:51:42
合計ジャッジ時間 2,121 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 3 ms
4,396 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
constexpr int INF = 1001001001;

int k;
void chmin(int &a, int x){
    if(a > x) a = x;
}

int f(vector<int> &memo, int n){
    if(n < 1) return INF;
    if(memo[n] == -1){
        memo[n] = INF;
        if(n > 1 && n % 2 == 0) chmin(memo[n], f(memo, n/2)+1);
        if(memo[n] == INF) chmin(memo[n], f(memo, n-3)+1);
    }
    return memo[n];
}

int main(){
    int n;
    cin >> n >> k;

    vector<int> memo(n+10, -1);
    memo[1] = 0;
    memo[2] = 1;
    memo[4] = 1;
    if(f(memo, n) <= k) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}
0