結果

問題 No.185 和風
ユーザー Lavender
提出日時 2019-09-03 10:51:59
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 424 bytes
コンパイル時間 1,602 ms
コンパイル使用メモリ 165,004 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 13:05:53
合計ジャッジ時間 2,110 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:22:16: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   22 |     else cout<<ans<<endl;
      |                ^~~
main.cpp:5:15: note: 'ans' was declared here
    5 |     int n,x,y,ans,flug=1;
      |               ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,y,ans,flug=1;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        if(i==0){
            ans=y-x;
            if(ans<=0){
                flug=0;
                break;
            }
        }
        if(ans!=y-x){
            flug=0;
          	break;
        }
    }
    if(flug==0)cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}
0