結果

問題 No.185 和風
ユーザー Syuutaro
提出日時 2018-03-16 19:24:00
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 633 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 22,656 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-21 14:37:51
合計ジャッジ時間 611 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |     scanf("%d",&N);
      |     ~~~~~^~~~~~~~~
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf("%d %d",&X[i],&Y[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
int main(){
    //input
    int N;
    scanf("%d",&N);

    int X[1000];
    int Y[1000];
    for (int i = 0;i < N;i++){
        scanf("%d %d",&X[i],&Y[i]);
    }

    //calculation
    int answer;
    for (int i = 0;i < N;i++){
        int tmp = Y[i]-X[i];
        if (tmp > 0){
            if (i == 0){
                answer = tmp;
            }else{
                if (answer != tmp){
                    answer = -1;
                    break;
                }
            }
        }else{
            answer = -1;
            break;
        }
    }

    //output
    printf("%d\n",answer);
    return 0;
}
0