結果

問題 No.999 てん vs. ほむ
ユーザー chocono2230chocono2230
提出日時 2020-03-06 12:51:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 836 bytes
コンパイル時間 1,395 ms
コンパイル使用メモリ 166,660 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 03:49:18
合計ジャッジ時間 3,281 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n*2);
	rep(snip_i, n*2) cin >> a.at(snip_i);
	
	ll ans = 0;
	ll p1 = 0, p2 = 0;
	rep(i, n+1){
		if(i == 0){
			rep(j, n){
				p2 += a.at(j*2); p1 += a.at(j*2+1);
			}
		}else{
			int ii = i - 1;
			p1 += a.at(ii*2); p1 -= a.at(ii*2+1);
			p2 -= a.at(ii*2); p2 += a.at(ii*2+1);
		}
		ll dif = p1 - p2;
		if(i == 0 || ans < dif) ans = dif;
	}
	cout << ans << endl;
	return 0;
}
0