結果

問題 No.185 和風
ユーザー R NR N
提出日時 2020-09-21 17:15:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 20 ms / 1,000 ms
コード長 652 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 8,296 KB
最終ジャッジ日時 2023-09-06 17:20:35
合計ジャッジ時間 835 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,744 KB
testcase_01 AC 20 ms
8,192 KB
testcase_02 AC 20 ms
8,296 KB
testcase_03 AC 19 ms
8,192 KB
testcase_04 AC 19 ms
8,176 KB
testcase_05 AC 16 ms
7,832 KB
testcase_06 AC 19 ms
8,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding=utf-8:

n = int(input())
numList = list()

for i in range(n):
    numList.append(list(map(int, input().split())))

sabunA = 0
sabunB = 0
count = 0
j, k = 0, 1

if n == 1:
    sabunA = numList[j][1] - numList[j][0]
    if sabunA < 0:
        print(-1)

elif n >= 2:
    while j == k - 1 and k != len(numList):
        sabunA = numList[j][1] - numList[j][0]
        sabunB = numList[k][1] - numList[k][0]
        if sabunA == sabunB:
            count += 1
            j += 1
            k += 1
        else:
            j += 1
            k += 1
    if count == len(numList) - 1 and sabunA > 0:
        print(sabunA)
    else:
        print(-1)
0