結果

問題 No.904 サメトロ
ユーザー face4
提出日時 2019-10-11 21:40:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 637 bytes
コンパイル時間 583 ms
コンパイル使用メモリ 69,908 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-25 07:03:27
合計ジャッジ時間 1,402 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;

int main(){
    int n;
    cin >> n;
    int asum = 0, bsum = 0;
    vector<int> a(n-1), b(n-1);
    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        asum += a, bsum += b;
    }
    int ans = 0;
    for(int i = 0; i <= bsum; i++){
        int j = asum+i-bsum;
        if(j < 0)   continue;
        int tmpa = asum+i, tmpb = bsum+j;
        if(i > tmpb-j)  continue;
        bool valid = true;
        for(int k = 0; k < n-1; k++){
            valid &= a[k] <= tmpb-b[k];
        }
        ans += valid;
    }
    cout << ans << endl;
    return 0;
}
0