結果

問題 No.999 てん vs. ほむ
ユーザー leaf_1415leaf_1415
提出日時 2020-02-28 21:27:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 441 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 56,792 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 17:49:31
合計ジャッジ時間 1,809 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 20 ms
5,376 KB
testcase_10 AC 6 ms
5,376 KB
testcase_11 AC 6 ms
5,376 KB
testcase_12 AC 10 ms
5,376 KB
testcase_13 AC 22 ms
5,376 KB
testcase_14 AC 21 ms
5,376 KB
testcase_15 AC 21 ms
5,376 KB
testcase_16 AC 22 ms
5,376 KB
testcase_17 AC 16 ms
5,376 KB
testcase_18 WA -
testcase_19 AC 15 ms
5,376 KB
testcase_20 WA -
testcase_21 AC 22 ms
5,376 KB
testcase_22 AC 21 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#define llint long long

using namespace std;

llint n;
llint a[100005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	llint x, y;
	for(int i = 1; i <= n; i++){
		cin >> x >> y;
		a[i] = x - y;
	}
	
	llint ans = 0, sum = 0;
	for(int i = 1; i <= n; i++) sum += a[i];
	for(int i = n; i >= 1; i--){
		sum -= 2*a[i];
		ans = max(ans, sum);
	}
	cout << ans << endl;
	
	return 0;
}
0