結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl  = vector<ll>;

#define REP(i,n) for(ll i=0; i<(n); ++i)

int main() {
	ll n; cin >> n;
	vl v(n); REP(i, n) cin >> v[i];
	pair<ll, ll> sum = {0,0};
	REP(i,n) {
		sum.first = max(sum.first, sum.second);
		sum.second += v[i];
		swap(sum.first, sum.second);
	}
	cout << max(sum.first, sum.second) << endl;

	return 0;
}
0