結果
問題 | No.320 眠れない夜に |
ユーザー |
|
提出日時 | 2023-03-01 21:57:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 551 bytes |
コンパイル時間 | 1,717 ms |
コンパイル使用メモリ | 169,556 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-16 19:03:11 |
合計ジャッジ時間 | 3,083 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 25 WA * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); ll n, m, ans = 1ll << 62; cin >> n >> m; vector<ll> a = {1, 1}; for(int i = 2; i < n; i++){ a.push_back(a[i - 1] + a[i - 2]); } auto f = [&](ll v){ ll res = 0; for(int i = n - 1; i >= 0; i--){ if(v >= a[i]){ v -= a[i]; res++; } } return v == 0 ? res : -1; }; cout << f(a.back() - m) << '\n'; }