結果

問題 No.999 てん vs. ほむ
ユーザー ゆにぽけゆにぽけ
提出日時 2023-10-21 16:37:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 722 bytes
コンパイル時間 1,489 ms
コンパイル使用メモリ 124,220 KB
実行使用メモリ 5,188 KB
最終ジャッジ日時 2023-10-21 16:37:57
合計ジャッジ時間 3,637 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 24 ms
5,044 KB
testcase_10 AC 9 ms
4,348 KB
testcase_11 AC 6 ms
4,348 KB
testcase_12 AC 12 ms
4,348 KB
testcase_13 AC 26 ms
5,188 KB
testcase_14 AC 27 ms
5,188 KB
testcase_15 AC 27 ms
5,188 KB
testcase_16 AC 27 ms
5,188 KB
testcase_17 AC 19 ms
5,068 KB
testcase_18 AC 19 ms
5,044 KB
testcase_19 AC 19 ms
5,068 KB
testcase_20 AC 19 ms
5,076 KB
testcase_21 AC 26 ms
5,100 KB
testcase_22 AC 25 ms
5,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cmath>
#include<ctime>
#include<iomanip>
#include<numeric>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<random>
using namespace std;
int N,A[2 << 17];
long long S[1 << 17];
void solve()
{
	cin >> N;
	for(int i = 0;i < 2*N;i++) cin >> A[i];
	for(int i = 0;i < N;i++) S[i+1] = S[i] + A[i*2]-A[i*2+1];
	long long ans = -(long long)1e18;
	for(int i = 0;i <= N;i++) ans = max(ans,S[i] + S[i] - S[N]);
	cout << ans << endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int tt = 1;
	//cin >> tt;
	while(tt--) solve();
}
0