結果
問題 |
No.320 眠れない夜に
|
ユーザー |
![]() |
提出日時 | 2015-12-13 00:08:03 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,194 bytes |
コンパイル時間 | 979 ms |
コンパイル使用メモリ | 105,060 KB |
実行使用メモリ | 52,480 KB |
最終ジャッジ日時 | 2024-09-15 08:54:27 |
合計ジャッジ時間 | 32,880 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 19 WA * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:60:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 60 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:61:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 61 | scanf("%lld", &m); | ~~~~~^~~~~~~~~~~~
ソースコード
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cctype> #include<cstdlib> #include<algorithm> #include<bitset> #include<vector> #include<list> #include<deque> #include<queue> #include<map> #include<set> #include<stack> #include<cmath> #include<sstream> #include<fstream> #include<iomanip> #include<ctime> #include<complex> #include<functional> #include<climits> #include<cassert> #include<iterator> #include<unordered_set> #include<unordered_map> #include<bitset> using namespace std; int n; long long int m; map<pair<long long int, long long int>, int> mp[82]; inline int dfs(int c,long long int a, long long int b){ if (clock() / (double)(CLOCKS_PER_SEC) > 1.5){ return -1; } if (b > m){ return -1; } if (c == n){ if (b == m){ return 0; } return -1; } if (mp[c].count(make_pair(a, b))){ return mp[c][make_pair(a, b)]; } int ans=dfs(c + 1, b, a + b); int ans2 = dfs(c + 1, b, a + b - 1LL); if (ans2 != -1){ if (ans == -1 || ans > ans2){ ans = ans2+1; } } mp[c][make_pair(a, b)] = ans; return mp[c][make_pair(a, b)]; } int main(){ scanf("%d", &n); scanf("%lld", &m); int ans=dfs(2, 1, 1); printf("%d\n", ans); return 0; }