結果

問題 No.185 和風
ユーザー むうすむうす
提出日時 2023-01-04 20:04:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 476 bytes
コンパイル時間 1,423 ms
コンパイル使用メモリ 167,752 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 22:24:35
合計ジャッジ時間 1,873 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:27:14: warning: 'd' may be used uninitialized [-Wmaybe-uninitialized]
   27 |        cout<<d<<endl;
      |              ^
main.cpp:9:8: note: 'd' was declared here
    9 |    int d;
      |        ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
int main(){
   int N;
   cin>>N;
   vector<int> X(N);
   vector<int> Y(N);
   int d;
   bool frag=true;
   for(int i=0;i<N;i++){
       cin>>X[i]>>Y[i];
       d=Y[0]-X[0];
       if(d<=0){
           frag=false;
           break;
       }
       else{
       if(Y[i]-X[i]!=d){
           frag=false;
           break;
       }
       }
       
   }
   if(frag){
       cout<<d<<endl;
   }
   else{
       cout<<-1<<endl;
   }
}
0