結果

問題 No.1120 Strange Teacher
ユーザー anagohirameanagohirame
提出日時 2020-07-22 22:25:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 119 ms / 1,000 ms
コード長 374 bytes
コンパイル時間 1,718 ms
コンパイル使用メモリ 86,500 KB
実行使用メモリ 101,064 KB
最終ジャッジ日時 2023-09-04 21:34:28
合計ジャッジ時間 5,083 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
70,860 KB
testcase_01 AC 76 ms
71,044 KB
testcase_02 AC 87 ms
75,440 KB
testcase_03 AC 85 ms
76,160 KB
testcase_04 AC 119 ms
100,884 KB
testcase_05 AC 119 ms
100,964 KB
testcase_06 AC 118 ms
101,064 KB
testcase_07 AC 119 ms
100,908 KB
testcase_08 AC 118 ms
100,860 KB
testcase_09 AC 74 ms
71,144 KB
testcase_10 AC 115 ms
100,856 KB
testcase_11 AC 115 ms
100,952 KB
testcase_12 AC 116 ms
100,932 KB
testcase_13 AC 116 ms
100,928 KB
testcase_14 AC 114 ms
100,928 KB
testcase_15 AC 115 ms
100,960 KB
testcase_16 AC 114 ms
100,956 KB
testcase_17 AC 115 ms
100,908 KB
testcase_18 AC 75 ms
70,876 KB
testcase_19 AC 117 ms
99,356 KB
testcase_20 AC 75 ms
71,228 KB
testcase_21 AC 73 ms
71,300 KB
testcase_22 AC 74 ms
71,224 KB
testcase_23 AC 74 ms
71,112 KB
testcase_24 AC 114 ms
100,068 KB
testcase_25 AC 74 ms
70,816 KB
testcase_26 AC 73 ms
71,168 KB
testcase_27 AC 74 ms
71,060 KB
testcase_28 AC 73 ms
71,200 KB
testcase_29 AC 79 ms
70,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import exit
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

if n == 2:
	if sum(a) == sum(b):
		print(abs(a[0] - b[0]))
	else:
		print(-1)
	exit()

s = sum(a) - sum(b)
if s % (n-2) != 0:
	print(-1)	
else:
	k = s // (n-2)
	for x, y in zip(a, b):
		z = y - x + k
		if z < 0 or z%2 != 0:
			print(-1)
			break
	else:
		print(k)
0