結果

問題 No.185 和風
ユーザー ldsybldsyb
提出日時 2016-02-27 13:14:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 363 bytes
コンパイル時間 575 ms
コンパイル使用メモリ 55,964 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 18:30:47
合計ジャッジ時間 902 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 1 ms
4,372 KB
testcase_05 AC 1 ms
4,372 KB
testcase_06 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:12: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   18 |    cout << ans << endl;
      |            ^~~

ソースコード

diff #

#include <iostream>
using namespace std;

int main(){
   int n,ans;
   cin >> n;
   int x[n],y[n];
   for(int i = 0;i < n;i++){
      cin >> x[i] >> y[i];
      if(y[i] - x[i] <= 0 || ans != y[i] - x[i]){
         cout << -1 << endl;
         return 0;
      }else if(i == 0){
         ans = y[i] - x[i];
         continue;
      }
   }
   cout << ans << endl;
}
0