結果

問題 No.999 てん vs. ほむ
ユーザー bal4ubal4u
提出日時 2020-03-01 06:42:36
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 30,720 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 22:05:59
合計ジャッジ時間 1,235 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// 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