結果

問題 No.904 サメトロ
ユーザー function6161
提出日時 2019-10-16 18:27:35
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 11 ms / 1,000 ms
コード長 487 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 55,404 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-22 18:13:28
合計ジャッジ時間 1,310 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:4:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    4 |     scanf("%d",&a);
      |     ~~~~~^~~~~~~~~
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%d %d",&b[i],&c[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <iostream>
int main(){
    int a,ans=0,x=0,y=0;
    scanf("%d",&a);
    int b[a-1],c[a-1];
    for(int i=0;i<a-1;i++){
        scanf("%d %d",&b[i],&c[i]);
        x+= *(b+i);
        y+= *(c+i);
    }
    for(int p = 0;p <= y;p++){
        int q = (x + p) - y;
        bool good = q >= 0;
        for(int i = 0;i< a-1;i++){
            if(b[i] > q + y -c[i]){
                good = false;
            }
        }
        ans += good;
    }
    std::cout << ans;
    return 0;
}
0