結果
| 問題 |
No.1120 Strange Teacher
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-20 03:47:29 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 185 ms / 1,000 ms |
| コード長 | 831 bytes |
| コンパイル時間 | 303 ms |
| コンパイル使用メモリ | 82,240 KB |
| 実行使用メモリ | 118,204 KB |
| 最終ジャッジ日時 | 2025-01-02 11:13:49 |
| 合計ジャッジ時間 | 7,401 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#!/usr/bin/env python3
# from typing import *
import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq
def input():
return sys.stdin.readline()[:-1]
# sys.setrecursionlimit(1000000)
# _INPUT = """# paste here...
# """
# sys.stdin = io.StringIO(_INPUT)
INF = 10**10
def solve(N, A, B):
D = [A[i]-B[i] for i in range(N)]
s = sum(D)
if N == 2:
if s != 0:
return -1
return abs(D[0])
else:
if s % (N-2) != 0:
return -1
n = s // (N-2)
for d in D:
d1 = d - n
if not (d1 % 2 == 0 and d1 <= 0):
return -1
return n
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
print(solve(N, A, B))