結果
問題 | No.1465 Archaea |
ユーザー |
![]() |
提出日時 | 2021-04-02 22:38:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 49 ms / 2,000 ms |
コード長 | 497 bytes |
コンパイル時間 | 1,907 ms |
コンパイル使用メモリ | 175,496 KB |
実行使用メモリ | 13,568 KB |
最終ジャッジ日時 | 2024-12-24 01:21:46 |
合計ジャッジ時間 | 2,775 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
コンパイルメッセージ
main.cpp: In function 'll solve(ll)': main.cpp:13:1: warning: control reaches end of non-void function [-Wreturn-type] 13 | } | ^
ソースコード
#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; }