結果

問題 No.1120 Strange Teacher
ユーザー takakintakakin
提出日時 2020-07-25 21:52:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 470 bytes
コンパイル時間 857 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 23,904 KB
最終ジャッジ日時 2023-09-10 00:33:28
合計ジャッジ時間 5,674 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,836 KB
testcase_01 AC 16 ms
7,848 KB
testcase_02 AC 17 ms
8,384 KB
testcase_03 AC 27 ms
9,836 KB
testcase_04 AC 127 ms
23,904 KB
testcase_05 AC 126 ms
23,776 KB
testcase_06 AC 128 ms
23,580 KB
testcase_07 AC 124 ms
23,844 KB
testcase_08 AC 122 ms
23,844 KB
testcase_09 AC 16 ms
7,988 KB
testcase_10 AC 79 ms
23,712 KB
testcase_11 AC 78 ms
23,588 KB
testcase_12 AC 79 ms
23,644 KB
testcase_13 AC 78 ms
23,900 KB
testcase_14 AC 78 ms
23,680 KB
testcase_15 AC 79 ms
23,760 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 16 ms
7,824 KB
testcase_19 AC 120 ms
23,788 KB
testcase_20 AC 16 ms
7,804 KB
testcase_21 AC 16 ms
7,784 KB
testcase_22 AC 16 ms
7,796 KB
testcase_23 AC 15 ms
7,860 KB
testcase_24 AC 116 ms
20,764 KB
testcase_25 AC 16 ms
7,932 KB
testcase_26 AC 16 ms
7,860 KB
testcase_27 AC 16 ms
7,856 KB
testcase_28 AC 15 ms
7,852 KB
testcase_29 AC 16 ms
7,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]

if n==2:
	if sum(A)==sum(B):
		print(abs(A[0]-B[0]))
	else:
		print(-1)
else:
	d=sum(A)-sum(B)
	if d<0 or d%(n-2)!=0:
		print(-1)
	else:
		ans=d//(n-2)
		ct=0
		Chk=True
		for i in range(n):
			if (B[i]-A[i]+ans)%2!=0:
				Chk=False
			ct+=(B[i]-A[i]+ans)//2
		if Chk==False or ct!=ans:
			print(-1)
		else:
			print(ans)





0