結果

問題 No.1120 Strange Teacher
ユーザー stngstng
提出日時 2022-09-04 19:30:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 130 ms / 1,000 ms
コード長 755 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 82,196 KB
実行使用メモリ 94,080 KB
最終ジャッジ日時 2024-04-29 19:23:38
合計ジャッジ時間 3,729 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
57,472 KB
testcase_01 AC 43 ms
58,112 KB
testcase_02 AC 41 ms
52,992 KB
testcase_03 AC 56 ms
63,744 KB
testcase_04 AC 91 ms
92,672 KB
testcase_05 AC 89 ms
91,812 KB
testcase_06 AC 82 ms
91,776 KB
testcase_07 AC 84 ms
92,032 KB
testcase_08 AC 82 ms
91,904 KB
testcase_09 AC 38 ms
51,840 KB
testcase_10 AC 74 ms
89,856 KB
testcase_11 AC 78 ms
89,728 KB
testcase_12 AC 74 ms
89,728 KB
testcase_13 AC 130 ms
94,080 KB
testcase_14 AC 128 ms
94,080 KB
testcase_15 AC 119 ms
93,508 KB
testcase_16 AC 127 ms
94,080 KB
testcase_17 AC 120 ms
93,608 KB
testcase_18 AC 38 ms
52,224 KB
testcase_19 AC 79 ms
92,800 KB
testcase_20 AC 38 ms
51,968 KB
testcase_21 AC 38 ms
52,096 KB
testcase_22 AC 38 ms
51,968 KB
testcase_23 AC 39 ms
51,712 KB
testcase_24 AC 82 ms
90,240 KB
testcase_25 AC 38 ms
52,224 KB
testcase_26 AC 86 ms
57,728 KB
testcase_27 AC 37 ms
51,712 KB
testcase_28 AC 37 ms
51,712 KB
testcase_29 AC 38 ms
51,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

li = [0]*n
ans = 0
parity = (b[0]-a[0])%2
for i in range(n):
    li[i] = b[i]-a[i]
    if li[i] % 2 != parity:
        print(-1)
        exit()

li.sort(reverse=True)
f = True
for i in range(n):
    if li[i] != 0:
        f = False
        break
if f == True:
    print(0)
    exit()

if li[n-1] > 0:
    print(-1)
    exit()

ttl = -li[n-1]
itr = 10**7
hiku = 0
tasu = 0

for i in range(n):
    tmp = (ttl+li[i])//2
    tasu += tmp
    hiku += ttl-tmp
#print(tasu,hiku,"ttl?")
if tasu*(n-1) == hiku:
    print(ttl)
    exit()

for i in range(itr):
    tasu += n
    hiku += n
    ttl += 2
    if tasu*(n-1) == hiku:
        print(ttl)
        exit()

print(-1)
0