結果
問題 |
No.1465 Archaea
|
ユーザー |
![]() |
提出日時 | 2024-11-15 00:13:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 634 bytes |
コンパイル時間 | 2,304 ms |
コンパイル使用メモリ | 197,440 KB |
最終ジャッジ日時 | 2025-02-25 04:14:16 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int n, k; cin >> n >> k; vector<int> dist(n + 1, 1e9); dist[1] = 0; deque<int> dq; dq.push_back(1); while (!dq.empty()) { int u = dq.front(); dq.pop_front(); if (u + 3 <= n) { if (dist[u + 3] > dist[u] + 1) { dist[u + 3] = dist[u] + 1; dq.push_back(u + 3); } } if (2 * u <= n) { if (dist[2 * u] > dist[u] + 1) { dist[2 * u] = dist[u] + 1; dq.push_front(2 * u); } } } if (dist[n] <= k) { cout << "YES\n"; } else { cout << "NO\n"; } }