結果
| 問題 |
No.1120 Strange Teacher
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-24 11:10:54 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 690 ms / 1,000 ms |
| コード長 | 552 bytes |
| コンパイル時間 | 225 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 51,428 KB |
| 最終ジャッジ日時 | 2024-06-24 21:44:09 |
| 合計ジャッジ時間 | 21,188 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
import numpy as np
N = int(input())
A = np.array([int(x) for x in input().split()])
B = np.array([int(x) for x in input().split()])
def main(A,B):
if N == 2:
if sum(A) != sum(B):
return -1
else:
return abs(A[0] - B[0])
else:
if sum(A) < sum(B) or (sum(A) - sum(B)) % (N - 2) != 0:
return -1
t = (sum(A) - sum(B)) // (N - 2)
A -= t
x = B - A
if np.all((x >= 0) & (x % 2 == 0)):
return t
else:
return -1
print(main(A,B))