結果

問題 No.1120 Strange Teacher
ユーザー vwxyzvwxyz
提出日時 2024-04-11 13:26:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 162 ms / 1,000 ms
コード長 445 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 24,976 KB
最終ジャッジ日時 2024-04-11 13:26:12
合計ジャッジ時間 4,346 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,752 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 31 ms
10,880 KB
testcase_03 AC 41 ms
12,288 KB
testcase_04 AC 135 ms
24,788 KB
testcase_05 AC 132 ms
24,780 KB
testcase_06 AC 162 ms
24,720 KB
testcase_07 AC 149 ms
24,784 KB
testcase_08 AC 138 ms
24,864 KB
testcase_09 AC 30 ms
10,752 KB
testcase_10 AC 105 ms
24,852 KB
testcase_11 AC 106 ms
24,852 KB
testcase_12 AC 108 ms
24,976 KB
testcase_13 AC 104 ms
24,780 KB
testcase_14 AC 102 ms
24,912 KB
testcase_15 AC 102 ms
24,732 KB
testcase_16 AC 120 ms
24,912 KB
testcase_17 AC 121 ms
24,732 KB
testcase_18 AC 31 ms
10,752 KB
testcase_19 AC 130 ms
24,824 KB
testcase_20 AC 33 ms
10,752 KB
testcase_21 AC 31 ms
10,752 KB
testcase_22 AC 33 ms
10,752 KB
testcase_23 AC 40 ms
10,752 KB
testcase_24 AC 125 ms
21,672 KB
testcase_25 AC 32 ms
10,752 KB
testcase_26 AC 35 ms
10,880 KB
testcase_27 AC 31 ms
10,752 KB
testcase_28 AC 31 ms
10,752 KB
testcase_29 AC 30 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
D=[a-b for a,b in zip(A,B)]
if N==2:
    if sum(D)==0:
        ans=abs(A[0]-B[0])
    else:
        ans=-1
else:
    if sum(D)<0 or sum(D)%(N-2):
        ans=-1
    else:
        cnt=sum(D)//(N-2)
        for i in range(N):
            A[i]-=cnt
        if all(a<=b and a%2==b%2 for a,b in zip(A,B)):
            ans=cnt
        else:
            ans=-1
print(ans)
0