結果

問題 No.1120 Strange Teacher
ユーザー 👑 H20H20
提出日時 2021-08-24 11:20:58
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 502 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 82,216 KB
実行使用メモリ 103,296 KB
最終ジャッジ日時 2024-04-26 15:14:34
合計ジャッジ時間 4,290 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,944 KB
testcase_01 AC 38 ms
53,352 KB
testcase_02 AC 41 ms
59,156 KB
testcase_03 AC 47 ms
64,972 KB
testcase_04 AC 87 ms
103,284 KB
testcase_05 AC 87 ms
103,044 KB
testcase_06 AC 87 ms
103,296 KB
testcase_07 AC 89 ms
103,216 KB
testcase_08 AC 88 ms
103,100 KB
testcase_09 AC 39 ms
52,664 KB
testcase_10 AC 81 ms
101,976 KB
testcase_11 AC 80 ms
101,616 KB
testcase_12 AC 78 ms
102,172 KB
testcase_13 AC 80 ms
101,668 KB
testcase_14 AC 80 ms
102,036 KB
testcase_15 AC 80 ms
101,668 KB
testcase_16 AC 80 ms
101,848 KB
testcase_17 AC 81 ms
101,780 KB
testcase_18 AC 38 ms
53,088 KB
testcase_19 AC 87 ms
101,120 KB
testcase_20 AC 37 ms
52,272 KB
testcase_21 AC 39 ms
52,624 KB
testcase_22 AC 38 ms
52,412 KB
testcase_23 AC 37 ms
51,872 KB
testcase_24 AC 81 ms
101,292 KB
testcase_25 AC 37 ms
53,012 KB
testcase_26 WA -
testcase_27 AC 37 ms
53,496 KB
testcase_28 AC 36 ms
53,052 KB
testcase_29 AC 37 ms
52,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
SA = sum(A)
SB = sum(B)
if N==2:
    if SA==SB:
        print(abs(B[0]-A[0]))
    else:
        print(-1)
    exit()


if (SA-SB)%(N-2)==0:
    cnt = (SA-SB)//(N-2)
    temp = 0
    for i in range(N):
        if B[i]-(A[i]-cnt)<0 or B[i]-(A[i]-cnt)%2==1:
            print(-1)
            exit()
        temp += B[i]-(A[i]-cnt)
    if temp//2==cnt:
        print(cnt)
    else:
        print(-1)
else:
    print(-1)
0