結果

問題 No.1465 Archaea
ユーザー DaYuanChi
提出日時 2021-04-02 22:27:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 477 bytes
コンパイル時間 1,902 ms
コンパイル使用メモリ 177,156 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-23 20:02:59
合計ジャッジ時間 2,759 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'll solve(ll)':
main.cpp:13:1: warning: control reaches end of non-void function [-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),solve((y-3)/2)+2);
  if(y%2==0) return memo[y] = 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