結果

問題 No.1465 Archaea
ユーザー Kanten4205
提出日時 2021-04-01 22:21:46
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 810 bytes
コンパイル時間 1,716 ms
コンパイル使用メモリ 170,104 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2024-12-24 01:08:49
合計ジャッジ時間 2,948 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef pair<bool, long long> P;
int main() {
	long long N, K; cin >> N >> K;
	assert(1 <= N && N <= 200000);
	assert(1 <= K && K <= 200000);
	vector<P>A(N + 1, make_pair(false, 1000000009));
	A.at(0) =make_pair(true, 0); A.at(1) = make_pair(true, 0);
	for (long long i = 2; i <= N; i++) {
		if (i % 2 == 0) {
			if (A.at(i / 2).first) A.at(i) = make_pair(true, min(A.at(i / 2).second + 1, A.at(i).second));
			if (i > 3) {
				if (A.at(i - 3).first) A.at(i) = make_pair(true, min(A.at(i - 3).second + 1, A.at(i).second));
			}
		}
		else {
			if (i > 3) {
				if (A.at(i - 3).first) A.at(i) = make_pair(true, min(A.at(i - 3).second + 1, A.at(i).second));
			}
		}
	}
	if (A.at(N).first && A.at(N).second <= K) cout << "YES" << endl;
	else cout << "NO" << endl;
}
0