結果

問題 No.999 てん vs. ほむ
コンテスト
ユーザー bal4u
提出日時 2020-03-01 06:42:36
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 549 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 215 ms
コンパイル使用メモリ 38,464 KB
最終ジャッジ日時 2026-02-22 05:24:26
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// yuki 999 てん vs. ほむ
// 2020.2.28 bal4u

#include <stdio.h>

typedef long long ll;

int getchar_unlocked(void);
#define gc() getchar_unlocked()

int in() {  // 整数の入力
	int n = 0; int c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

ll s[100005];
int main()
{
	int i, N;
	ll ans, t;

	N = in();
	for (i = 1; i <= N; ++i) {
		s[i] = s[i-1] + (in() - in());
	}
	ans = -0xfffffffffffffffLL;
	for (i = 0; i <= N; ++i) {
		t = (s[i] << 1);
		if (t > ans) ans = t;
	}
	printf("%lld\n", ans-s[N]);
	return 0;
}
0