結果

問題 No.999 てん vs. ほむ
ユーザー misora192misora192
提出日時 2020-04-19 16:00:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 715 bytes
コンパイル時間 1,778 ms
コンパイル使用メモリ 166,356 KB
実行使用メモリ 8,064 KB
最終ジャッジ日時 2024-04-15 15:11:55
合計ジャッジ時間 3,794 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 WA -
testcase_04 AC 2 ms
6,940 KB
testcase_05 WA -
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 WA -
testcase_10 AC 10 ms
6,940 KB
testcase_11 AC 8 ms
6,940 KB
testcase_12 WA -
testcase_13 AC 32 ms
8,064 KB
testcase_14 AC 31 ms
7,808 KB
testcase_15 AC 31 ms
7,936 KB
testcase_16 WA -
testcase_17 AC 23 ms
7,552 KB
testcase_18 AC 23 ms
7,424 KB
testcase_19 AC 23 ms
7,424 KB
testcase_20 AC 23 ms
7,552 KB
testcase_21 AC 31 ms
7,808 KB
testcase_22 AC 30 ms
7,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;

	vector<ll> a(2 * n);
	rep(i, 2 * n) cin >> a[i];

	vector<ll> elcum(n+1, 0), ercum(n+1, 0);
	vector<ll> olcum(n+1, 0), orcum(n+1, 0);
	rep(i, n){
		elcum[i + 1] = elcum[i] + a[2 * i]; 
		olcum[i + 1] = olcum[i] + a[2 * i + 1];
	}

	for(int i = n - 1; i >= 0; i--){
		ercum[i] = ercum[i+1] + a[2 * i];
		orcum[i] = orcum[i+1] + a[2 * i + 1];
	}

	ll ans = 0;
	rep(i, n){
		ans = max(ans, elcum[i] + orcum[i] - (olcum[i] + ercum[i]));
		ans = max(ans, olcum[i] + ercum[i] - (elcum[i] + orcum[i]));
	}

	cout << ans << endl;
}
0