結果

問題 No.904 サメトロ
ユーザー ngtkana
提出日時 2020-03-09 14:19:31
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 594 bytes
コンパイル時間 1,640 ms
コンパイル使用メモリ 168,584 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-07 23:07:50
合計ジャッジ時間 2,827 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define endl enjoy_codeforces
int main(){
    int n;std::cin>>n;
    n--;
    std::vector<int>a(n),b(n);
    for(int i=0;i<n;i++){
        std::cin>>a.at(i)>>b.at(i);
    }
    if(std::accumulate(a.begin(),a.end(),0)
            >std::accumulate(b.begin(),b.end(),0)){
        std::swap(a,b);
    }
    int A=std::accumulate(a.begin(),a.end(),0);
    int B=std::accumulate(b.begin(),b.end(),0);
    for(int i=0;i<n;i++){
        if(a.at(i)+b.at(i)>B){
            std::cout<<A-a.at(i)+B-b.at(i)+1<<'\n';
            return 0;
        }
    }
    std::cout<<A+1<<'\n';
}
0