結果

問題 No.904 サメトロ
ユーザー kuhaku
提出日時 2019-10-12 11:34:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 14 ms / 1,000 ms
コード長 593 bytes
コンパイル時間 1,418 ms
コンパイル使用メモリ 167,188 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 14:02:54
合計ジャッジ時間 2,388 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef long long ll;

int main(void){
	int n;
	cin >> n;

	int sum[2] = {}, a[n] = {}, b[n] = {};
	REP(i, n-1){
		cin >> a[i+1] >> b[i+1];
		sum[0] += a[i+1];
		sum[1] += b[i+1];
	}

	int ans = 0;
	REP(i, MIN(sum[0], sum[1])+1){
		a[0] = sum[1]-i; b[0] = sum[0]-i;
		REP(j, n){
			if(a[j] > sum[1]+b[0]-b[j]){
				cout << ans << endl;
				return 0;
			}
		}
		ans++;
	}

	cout << ans << endl;

	return 0;
}
0