結果

問題 No.1120 Strange Teacher
ユーザー stngstng
提出日時 2022-09-04 19:28:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 742 bytes
コンパイル時間 703 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 94,576 KB
最終ジャッジ日時 2024-04-29 19:22:13
合計ジャッジ時間 3,980 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 89 ms
93,056 KB
testcase_05 AC 87 ms
92,248 KB
testcase_06 AC 81 ms
91,904 KB
testcase_07 AC 81 ms
91,896 KB
testcase_08 AC 83 ms
91,776 KB
testcase_09 AC 39 ms
52,352 KB
testcase_10 AC 73 ms
90,444 KB
testcase_11 AC 78 ms
89,964 KB
testcase_12 AC 75 ms
90,240 KB
testcase_13 AC 141 ms
94,364 KB
testcase_14 AC 134 ms
94,208 KB
testcase_15 AC 124 ms
93,824 KB
testcase_16 AC 131 ms
94,576 KB
testcase_17 AC 122 ms
93,520 KB
testcase_18 AC 39 ms
52,096 KB
testcase_19 AC 79 ms
92,940 KB
testcase_20 AC 38 ms
52,352 KB
testcase_21 AC 38 ms
52,224 KB
testcase_22 AC 38 ms
52,736 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 39 ms
51,968 KB
testcase_26 AC 87 ms
58,112 KB
testcase_27 AC 38 ms
52,608 KB
testcase_28 AC 39 ms
52,608 KB
testcase_29 AC 39 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
    if tasu*(n-1) == hiku:
        print(ttl)
        exit()

print(-1)
0