結果

問題 No.314 ケンケンパ
ユーザー aaaaaa
提出日時 2018-11-10 10:48:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,026 bytes
コンパイル時間 877 ms
コンパイル使用メモリ 95,160 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2024-05-02 20:26:23
合計ジャッジ時間 1,918 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
7,168 KB
testcase_01 AC 5 ms
7,168 KB
testcase_02 AC 5 ms
7,168 KB
testcase_03 AC 5 ms
7,168 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 4 ms
7,168 KB
testcase_12 AC 5 ms
7,168 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>

using namespace std;


int main(){
	int i, j;
	int n;
	vector<int>dp(1000006, 0);


	cin >> n;

	//dp[1] = 1;
	//dp[2] = 1;

	for (i = 1; i < n; i++) {

		for (j = i + 2; j <= i + 3; j++) {
			dp[j] =  dp[i] + 1  +  ( dp[j] );
			//dp[j] = dp[i] + 1;
			dp[j] %= 1000000007;
		}

	}

	long maxn = 0, index = 0;

	for (i = n - 2; i <= n + 1; i++) {
		if (maxn < dp[i]) {
			maxn = dp[i];
			index = i;
		}
	}

	if (index < n) {
		cout << maxn + ((n + 1) - index) << endl;
	}
	else {
		cout << maxn << endl;
	}
	//cout << dp[n + 1] << endl;

	//long sum = 0;

	/*for (i = 0; i < n; i++) {
		sum += dp[i];
		sum %= 1000000007;
	}
	cout << sum << endl;
*/







	getchar();
	getchar();
	return 0;
}
0