結果

問題 No.320 眠れない夜に
ユーザー Kmcode1Kmcode1
提出日時 2015-12-13 00:08:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,194 bytes
コンパイル時間 1,965 ms
コンパイル使用メモリ 104,076 KB
実行使用メモリ 48,660 KB
最終ジャッジ日時 2023-10-13 11:59:04
合計ジャッジ時間 34,110 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,573 ms
46,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1,578 ms
46,604 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1,573 ms
46,392 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 59 ms
5,332 KB
testcase_16 AC 1,576 ms
46,472 KB
testcase_17 AC 1,577 ms
46,608 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,352 KB
testcase_20 WA -
testcase_21 AC 246 ms
10,924 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 5 ms
4,352 KB
testcase_24 AC 1 ms
4,352 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 466 ms
17,260 KB
testcase_27 AC 3 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 WA -
testcase_34 AC 1 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0