結果

問題 No.185 和風
ユーザー kpinkcatkpinkcat
提出日時 2023-08-03 14:21:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 621 bytes
コンパイル時間 947 ms
コンパイル使用メモリ 105,400 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 12:42:56
合計ジャッジ時間 1,751 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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