結果

問題 No.1465 Archaea
ユーザー DaYuanChiDaYuanChi
提出日時 2021-04-02 22:38:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 1,400 ms
コンパイル使用メモリ 173,736 KB
実行使用メモリ 13,500 KB
最終ジャッジ日時 2023-08-25 16:18:41
合計ジャッジ時間 2,515 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 10 ms
5,812 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 12 ms
5,928 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 13 ms
6,500 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 35 ms
11,056 KB
testcase_14 AC 10 ms
5,740 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 36 ms
11,596 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 15 ms
7,100 KB
testcase_20 AC 19 ms
7,420 KB
testcase_21 AC 46 ms
13,500 KB
testcase_22 AC 46 ms
13,500 KB
testcase_23 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘ll solve(ll)’ 内:
main.cpp:13:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   13 | }
      | ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
map<ll, ll> memo;
 
ll solve(ll y){
  if(memo.find(y) != memo.end()) return memo[y];
  if(y==1) return memo[1] = 0;
  if(y%2==1 && y!=3) return memo[y] = min(solve(y-3)+1,solve((y-3)/2)+2);
  if(y%2==0) return memo[y] = min(solve(y-3)+1,solve(y/2)+1);
  if(y==3) return memo[y] = 1e9;
}
 
int main(){
  int x, k; cin >> x >> k;
  int m = solve(x);
  if(m<=k) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}
  
0