結果

問題 No.45 回転寿司
ユーザー ant2357
提出日時 2016-05-03 14:25:17
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 493 bytes
コンパイル時間 1,310 ms
コンパイル使用メモリ 85,732 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-27 13:15:26
合計ジャッジ時間 1,951 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <deque>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;

	vector<int>susiV(n);
	for (int i = 0; i < n; i++) {
		cin >> susiV[i];
	}

	vector<int>dp(2);
	for (int i = 0; i < n; i++) {
		vector<int> dptmp(2);
		dptmp[0] = max(dp[0], dp[1]);
		dptmp[1] = dp[0] + susiV[i];
		dp = dptmp;
	}

	int ans = max(dp[0], dp[1]);
	cout << ans << endl;
	return 0;
}
0