結果

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

ソースコード

diff #

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

int main(){
    int N, A[36], B[36];
    cin >> N;
    int as = 0, bs = 0;
    for(int i=0; i<N-1; i++){
        cin >> A[i] >> B[i];
        as += A[i];
        bs += B[i];
    }
    int amin = max(0, bs-as);
    for(int i=0; i<N-1; i++) amin = max(amin, A[i] + B[i] - as);
    int amax = bs;
    int ans = max(0, amax-amin+1);
    cout << ans << endl;
}
0