結果

問題 No.904 サメトロ
ユーザー mtrhmtrh
提出日時 2022-02-12 22:31:36
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 624 bytes
コンパイル時間 3,637 ms
コンパイル使用メモリ 229,272 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-29 01:46:18
合計ジャッジ時間 4,264 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#include<atcoder/all>
using namespace atcoder;

using ll=long long;

int main(){
    int N;
    cin>>N;
    int sumA=0,sumB=0;
    vector<int> A(N-1),B(N-1);
    for(int i=0;i<N-1;i++){
        cin>>A[i]>>B[i];
        sumA+=A[i],sumB+=B[i];
    }
    int ans=0;
    for(int A1=0;A1<=sumB;A1++){
        int B1=A1+sumA-sumB;
        sumA+=A1,sumB+=B1;
        if(A1<0||B1<0) continue;
        bool f=true;
        for(int i=0;i<N-1;i++){
            if(A[i]>sumB-B[i]) f=false;
        }
        if(f) ans++;
        sumA-=A1,sumB-=B1;
    }
    cout<<ans<<endl;
    return 0;
}
0