結果

問題 No.185 和風
ユーザー r2en_
提出日時 2017-03-17 13:42:47
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 483 bytes
コンパイル時間 624 ms
コンパイル使用メモリ 63,488 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-04 13:41:12
合計ジャッジ時間 1,146 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:17:10: warning: 'z' may be used uninitialized [-Wmaybe-uninitialized]
   17 |     crct = z[0];
      |     ~~~~~^~~~~~
main.cpp:9:15: note: 'z' declared here
    9 |     long long z[1000];
      |               ^

ソースコード

diff #

#include <iostream>
using namespace std;

int main(){
    int N;
    int cnt = 0;
    long long x[1000];
    long long y[1000];
    long long z[1000];
    long long crct;
    scanf("%d",&N);

    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i];
        z[i] = y[i] - x[i];
    }
    crct = z[0];
    for(int i = 0; i < N; i++){
        if(crct == z[i])cnt++;
    }
    if(N==1)cout << "-1\n";
    else if(cnt==N) cout << z[0] << "\n";
    else cout << "-1\n";
    return 0;
}
0