結果

問題 No.1120 Strange Teacher
ユーザー roarisroaris
提出日時 2020-07-24 21:35:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 608 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 86,876 KB
実行使用メモリ 99,956 KB
最終ジャッジ日時 2023-09-08 03:34:24
合計ジャッジ時間 4,874 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,204 KB
testcase_01 AC 70 ms
71,396 KB
testcase_02 AC 73 ms
75,776 KB
testcase_03 AC 78 ms
76,516 KB
testcase_04 AC 121 ms
99,692 KB
testcase_05 AC 121 ms
99,852 KB
testcase_06 AC 122 ms
99,736 KB
testcase_07 AC 121 ms
99,780 KB
testcase_08 AC 120 ms
99,708 KB
testcase_09 AC 70 ms
71,132 KB
testcase_10 AC 110 ms
99,864 KB
testcase_11 AC 109 ms
99,780 KB
testcase_12 AC 109 ms
99,956 KB
testcase_13 AC 118 ms
99,736 KB
testcase_14 AC 120 ms
99,664 KB
testcase_15 AC 121 ms
99,700 KB
testcase_16 AC 119 ms
99,860 KB
testcase_17 AC 119 ms
99,956 KB
testcase_18 AC 71 ms
71,272 KB
testcase_19 AC 120 ms
98,212 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 70 ms
71,624 KB
testcase_23 AC 69 ms
71,544 KB
testcase_24 AC 117 ms
99,448 KB
testcase_25 AC 70 ms
71,256 KB
testcase_26 AC 70 ms
71,104 KB
testcase_27 AC 71 ms
71,284 KB
testcase_28 AC 70 ms
71,520 KB
testcase_29 AC 70 ms
71,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = [B[i]-A[i] for i in range(N)]

if N==2:
    if C[0]!=C[1]:
        print(-1)
    else:
        print(abs(C[0]))
    exit()
    
D = []

for i in range(1, N):
    if (C[0]-C[i])%2==1:
        print(-1)
        exit()
    
    D.append((C[0]-C[i])//2)

S = sum(D)

if (S-C[0])%(N-2)!=0:
    print(-1)
    exit()

x = (S-C[0])//(N-2)

if x<0:
    print(-1)
    exit()
    
ans = x

for Di in D:
    if x-Di<0:
        print(-1)
        exit()
        
    ans += x-Di

print(ans)
0