結果

問題 No.185 和風
ユーザー kpinkcat
提出日時 2023-08-03 14:21:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 621 bytes
コンパイル時間 942 ms
コンパイル使用メモリ 102,680 KB
最終ジャッジ日時 2025-02-15 21:47:03
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:34:13: warning: ‘temp’ may be used uninitialized [-Wmaybe-uninitialized]
   34 |     cout << temp << endl;
      |             ^~~~
main.cpp:23:12: note: ‘temp’ was declared here
   23 |     int n, temp;
      |            ^~~~

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
#include<set>
#include<bitset>
#include<math.h>
#include<map>
#include<queue>
#include<iomanip>
using namespace std;

int digisum(int i){
    int sum1 = 0;
    while (i) {
        sum1 += i%10;
        i /= 10;
    }
    return sum1;
}

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