結果

問題 No.45 回転寿司
ユーザー elphe
提出日時 2024-08-09 20:17:06
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 401 bytes
コンパイル時間 505 ms
コンパイル使用メモリ 66,068 KB
最終ジャッジ日時 2025-02-23 21:10:33
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdint>

using namespace std;

int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	uint16_t N, i, V;
	uint32_t dp[2][2] = { {0, 0}, {0, 0} };

	cin >> N;
	for (i = 0; i != N; ++i)
	{
		cin >> V;
		dp[(i & 1) ^ 1][0] = max(dp[i & 1][0], dp[i & 1][1]);
		dp[(i & 1) ^ 1][1] = dp[i & 1][0] + V;
	}

	cout << max(dp[N & 1][0], dp[N & 1][1]) << '\n';
	return 0;
}
0