結果

問題 No.1120 Strange Teacher
ユーザー 👑 H20H20
提出日時 2021-08-24 11:24:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 87 ms / 1,000 ms
コード長 504 bytes
コンパイル時間 384 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 103,548 KB
最終ジャッジ日時 2024-04-26 15:19:01
合計ジャッジ時間 3,635 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,248 KB
testcase_01 AC 37 ms
52,468 KB
testcase_02 AC 40 ms
59,312 KB
testcase_03 AC 46 ms
65,496 KB
testcase_04 AC 85 ms
103,152 KB
testcase_05 AC 83 ms
103,228 KB
testcase_06 AC 83 ms
103,472 KB
testcase_07 AC 82 ms
103,304 KB
testcase_08 AC 84 ms
103,548 KB
testcase_09 AC 37 ms
53,332 KB
testcase_10 AC 78 ms
101,560 KB
testcase_11 AC 77 ms
101,692 KB
testcase_12 AC 79 ms
101,768 KB
testcase_13 AC 79 ms
101,360 KB
testcase_14 AC 77 ms
101,640 KB
testcase_15 AC 77 ms
101,864 KB
testcase_16 AC 78 ms
101,928 KB
testcase_17 AC 77 ms
102,164 KB
testcase_18 AC 37 ms
52,196 KB
testcase_19 AC 87 ms
101,000 KB
testcase_20 AC 39 ms
53,868 KB
testcase_21 AC 37 ms
52,796 KB
testcase_22 AC 38 ms
54,004 KB
testcase_23 AC 36 ms
52,692 KB
testcase_24 AC 78 ms
101,360 KB
testcase_25 AC 37 ms
52,144 KB
testcase_26 AC 38 ms
53,672 KB
testcase_27 AC 38 ms
53,160 KB
testcase_28 AC 37 ms
51,956 KB
testcase_29 AC 38 ms
54,088 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