結果

問題 No.1465 Archaea
ユーザー Manuel1024Manuel1024
提出日時 2021-04-04 19:45:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 546 bytes
コンパイル時間 699 ms
コンパイル使用メモリ 68,268 KB
実行使用メモリ 8,768 KB
最終ジャッジ日時 2023-08-27 21:06:53
合計ジャッジ時間 4,645 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
constexpr int INF = 1001001001;
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] == INF){
        if(n > 1 && n % 2 == 0) chmin(memo[n], f(memo, n/2)+1);
        chmin(memo[n], f(memo, n-3)+1);
    }
    return memo[n];
}

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

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