結果

問題 No.1120 Strange Teacher
ユーザー tikitaka1201tikitaka1201
提出日時 2020-07-24 14:47:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 125 ms / 1,000 ms
コード長 368 bytes
コンパイル時間 488 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 101,052 KB
最終ジャッジ日時 2023-09-07 08:50:07
合計ジャッジ時間 5,003 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,240 KB
testcase_01 AC 72 ms
71,200 KB
testcase_02 AC 76 ms
75,372 KB
testcase_03 AC 79 ms
76,340 KB
testcase_04 AC 119 ms
98,488 KB
testcase_05 AC 123 ms
98,444 KB
testcase_06 AC 124 ms
98,452 KB
testcase_07 AC 122 ms
98,360 KB
testcase_08 AC 125 ms
98,508 KB
testcase_09 AC 71 ms
71,276 KB
testcase_10 AC 117 ms
97,664 KB
testcase_11 AC 118 ms
97,960 KB
testcase_12 AC 122 ms
97,816 KB
testcase_13 AC 120 ms
98,560 KB
testcase_14 AC 119 ms
98,236 KB
testcase_15 AC 119 ms
98,324 KB
testcase_16 AC 118 ms
98,440 KB
testcase_17 AC 120 ms
98,336 KB
testcase_18 AC 73 ms
71,240 KB
testcase_19 AC 122 ms
96,872 KB
testcase_20 AC 71 ms
71,268 KB
testcase_21 AC 73 ms
71,092 KB
testcase_22 AC 72 ms
71,132 KB
testcase_23 AC 72 ms
71,272 KB
testcase_24 AC 119 ms
101,052 KB
testcase_25 AC 72 ms
71,332 KB
testcase_26 AC 69 ms
70,924 KB
testcase_27 AC 71 ms
71,064 KB
testcase_28 AC 72 ms
71,004 KB
testcase_29 AC 73 ms
71,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
*a,=map(int,input().split())
*b,=map(int,input().split())
dif=sum(a)-sum(b)

if n==2:
    if dif!=0:
        print(-1)
    else:
        print(abs(a[0]-b[0]))
elif dif>=0 and dif%(n-2)==0:
    x=dif//(n-2)
    for i in range(n):
        if (b[i]-(a[i]-x))%2==1 or b[i]<(a[i]-x):
            print(-1)
            exit()
    print(x)
else:
    print(-1)
0