結果

問題 No.1120 Strange Teacher
ユーザー 👑 KazunKazun
提出日時 2020-10-31 19:48:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 122 ms / 1,000 ms
コード長 396 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 99,984 KB
最終ジャッジ日時 2023-09-29 10:35:50
合計ジャッジ時間 5,980 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,368 KB
testcase_01 AC 72 ms
71,388 KB
testcase_02 AC 77 ms
75,856 KB
testcase_03 AC 80 ms
76,448 KB
testcase_04 AC 122 ms
99,644 KB
testcase_05 AC 112 ms
99,612 KB
testcase_06 AC 113 ms
99,800 KB
testcase_07 AC 114 ms
99,700 KB
testcase_08 AC 112 ms
99,984 KB
testcase_09 AC 70 ms
71,300 KB
testcase_10 AC 108 ms
99,748 KB
testcase_11 AC 110 ms
99,752 KB
testcase_12 AC 111 ms
99,672 KB
testcase_13 AC 117 ms
99,640 KB
testcase_14 AC 110 ms
99,704 KB
testcase_15 AC 109 ms
99,696 KB
testcase_16 AC 114 ms
99,700 KB
testcase_17 AC 110 ms
99,692 KB
testcase_18 AC 68 ms
71,176 KB
testcase_19 AC 110 ms
97,996 KB
testcase_20 AC 69 ms
71,272 KB
testcase_21 AC 69 ms
71,388 KB
testcase_22 AC 68 ms
71,344 KB
testcase_23 AC 69 ms
71,580 KB
testcase_24 AC 119 ms
99,376 KB
testcase_25 AC 70 ms
71,228 KB
testcase_26 AC 70 ms
71,464 KB
testcase_27 AC 70 ms
71,348 KB
testcase_28 AC 69 ms
71,312 KB
testcase_29 AC 70 ms
71,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

if N==2:
    if sum(A)==sum(B):
        print(abs(A[0]-B[0]))
    else:
        print(-1)
    exit()

D=[B[i]-A[i] for i in range(N)]
X=-sum(D)

P=0
for d in D:
    y=X+(N-2)*d
    if not(y>=0 and y%(2*(N-2))==0):
        print(-1)
        exit()

    P+=y//(2*(N-2))

print(P)
0