結果

問題 No.1120 Strange Teacher
ユーザー 👑 KazunKazun
提出日時 2020-07-22 22:15:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 121 ms / 1,000 ms
コード長 427 bytes
コンパイル時間 1,089 ms
コンパイル使用メモリ 86,848 KB
実行使用メモリ 101,240 KB
最終ジャッジ日時 2023-09-04 21:11:41
合計ジャッジ時間 5,479 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,288 KB
testcase_01 AC 73 ms
70,972 KB
testcase_02 AC 78 ms
75,804 KB
testcase_03 AC 79 ms
76,624 KB
testcase_04 AC 117 ms
101,168 KB
testcase_05 AC 119 ms
101,180 KB
testcase_06 AC 118 ms
101,156 KB
testcase_07 AC 117 ms
101,188 KB
testcase_08 AC 117 ms
101,100 KB
testcase_09 AC 72 ms
71,544 KB
testcase_10 AC 119 ms
101,116 KB
testcase_11 AC 121 ms
101,192 KB
testcase_12 AC 119 ms
101,176 KB
testcase_13 AC 116 ms
101,176 KB
testcase_14 AC 118 ms
101,136 KB
testcase_15 AC 118 ms
101,184 KB
testcase_16 AC 118 ms
101,136 KB
testcase_17 AC 118 ms
101,240 KB
testcase_18 AC 71 ms
71,352 KB
testcase_19 AC 117 ms
99,640 KB
testcase_20 AC 72 ms
71,416 KB
testcase_21 AC 72 ms
71,132 KB
testcase_22 AC 72 ms
71,484 KB
testcase_23 AC 73 ms
71,464 KB
testcase_24 AC 115 ms
100,412 KB
testcase_25 AC 72 ms
71,256 KB
testcase_26 AC 73 ms
71,192 KB
testcase_27 AC 71 ms
71,272 KB
testcase_28 AC 72 ms
71,284 KB
testcase_29 AC 72 ms
71,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

if N>=3:
    F=True
    H=0
    M=2*(N-2)
    for i in range(N):
        X=E-(N-2)*D[i]
        if X>=0 and X%M==0:
            H+=X//M
        else:
            F=False

    if F:
        print(H)
    else:
        print(-1)
else:
    if E==0:
        print(abs(A[0]-B[0]))
    else:
        print(-1)
0