結果

問題 No.45 回転寿司
ユーザー hotpepsi
提出日時 2015-06-22 00:57:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 441 bytes
コンパイル時間 573 ms
コンパイル使用メモリ 60,280 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-27 11:36:43
合計ジャッジ時間 1,563 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstring>

using namespace std;

int main(int argc, char *argv[]) {
	string s;
	getline(cin, s);
	int N = atoi(s.c_str());
	getline(cin, s);
	stringstream ss(s);
	int m[1008] = {};
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int n;
		ss >> n;
		int a = max(m[i - 2 + 4] + n, m[i - 3 + 4] + n);
		m[i + 4] = a;
		ans = max(ans, a);
	}
	cout << ans << endl;
	return 0;
}
0