結果

問題 No.185 和風
ユーザー lam6er
提出日時 2025-03-31 17:18:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 54 ms / 1,000 ms
コード長 385 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 82,540 KB
実行使用メモリ 63,332 KB
最終ジャッジ日時 2025-03-31 17:19:07
合計ジャッジ時間 957 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
ans = None
valid = True

for _ in range(n):
    x, y = map(int, input().split())
    diff = y - x
    # Check if diff is non-positive
    if diff <= 0:
        valid = False
    # Check if all diffs are the same
    if ans is None:
        ans = diff
    else:
        if diff != ans:
            valid = False

if valid and ans > 0:
    print(ans)
else:
    print(-1)
0