結果

問題 No.1120 Strange Teacher
ユーザー googol_S0googol_S0
提出日時 2020-07-22 21:28:09
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 141 ms / 1,000 ms
コード長 400 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 10,784 KB
実行使用メモリ 23,840 KB
最終ジャッジ日時 2023-09-04 15:12:52
合計ジャッジ時間 3,671 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,832 KB
testcase_01 AC 16 ms
7,796 KB
testcase_02 AC 17 ms
8,288 KB
testcase_03 AC 29 ms
9,660 KB
testcase_04 AC 136 ms
23,608 KB
testcase_05 AC 138 ms
23,464 KB
testcase_06 AC 137 ms
23,600 KB
testcase_07 AC 136 ms
23,460 KB
testcase_08 AC 141 ms
23,604 KB
testcase_09 AC 16 ms
8,132 KB
testcase_10 AC 74 ms
23,676 KB
testcase_11 AC 74 ms
23,732 KB
testcase_12 AC 75 ms
23,676 KB
testcase_13 AC 75 ms
23,720 KB
testcase_14 AC 76 ms
23,612 KB
testcase_15 AC 75 ms
23,656 KB
testcase_16 AC 89 ms
23,464 KB
testcase_17 AC 88 ms
23,684 KB
testcase_18 AC 17 ms
8,080 KB
testcase_19 AC 75 ms
23,840 KB
testcase_20 AC 16 ms
8,216 KB
testcase_21 AC 16 ms
8,124 KB
testcase_22 AC 16 ms
8,096 KB
testcase_23 AC 16 ms
7,816 KB
testcase_24 AC 132 ms
20,556 KB
testcase_25 AC 15 ms
8,124 KB
testcase_26 AC 16 ms
8,180 KB
testcase_27 AC 16 ms
7,952 KB
testcase_28 AC 16 ms
7,896 KB
testcase_29 AC 15 ms
8,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
if A==B:
  print(0)
  exit()
if N==2:
  if sum(A)!=sum(B):
    print(-1)
  else:
    print(abs(A[0]-B[0]))
  exit()
X=sum(A)-sum(B)
if X<=0 or X%(N-2):
  print(-1)
  exit()
X//=N-2
for i in range(N):
  A[i]-=X
P=0
for i in range(N):
  if A[i]>B[i] or (B[i]-A[i])&1:
    print(-1)
    exit()
  P+=(B[i]-A[i])//2
print(P)
0