結果

問題 No.185 和風
ユーザー 👑 CleyL
提出日時 2020-01-08 01:48:54
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 396 bytes
コンパイル時間 501 ms
コンパイル使用メモリ 63,712 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-23 01:49:38
合計ジャッジ時間 960 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:20:13: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   20 |     cout << ans << endl;
      |             ^~~
main.cpp:5:9: note: 'ans' was declared here
    5 |     int ans;
      |         ^~~

ソースコード

diff #

#include <iostream>
using namespace std;
int main(){
    int n;cin>>n;
    int ans;
    for(int i = 0; n > i; i++){
        int a,b;cin>>a>>b;
        if(a >= b){
            cout << -1 << endl;
            return 0;
        }
        if(!i){
            ans = b-a;
        }
        if(b-a != ans){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}
0