結果

問題 No.1120 Strange Teacher
ユーザー tcltktcltk
提出日時 2021-11-20 03:47:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 252 ms / 1,000 ms
コード長 831 bytes
コンパイル時間 1,072 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 113,400 KB
最終ジャッジ日時 2023-08-30 17:39:14
合計ジャッジ時間 12,092 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 191 ms
80,652 KB
testcase_01 AC 197 ms
81,024 KB
testcase_02 AC 201 ms
81,628 KB
testcase_03 AC 212 ms
84,240 KB
testcase_04 AC 247 ms
112,708 KB
testcase_05 AC 245 ms
112,840 KB
testcase_06 AC 249 ms
112,968 KB
testcase_07 AC 250 ms
112,840 KB
testcase_08 AC 247 ms
112,712 KB
testcase_09 AC 203 ms
80,836 KB
testcase_10 AC 248 ms
112,572 KB
testcase_11 AC 246 ms
112,808 KB
testcase_12 AC 239 ms
112,708 KB
testcase_13 AC 236 ms
112,728 KB
testcase_14 AC 246 ms
112,696 KB
testcase_15 AC 242 ms
112,664 KB
testcase_16 AC 246 ms
112,760 KB
testcase_17 AC 243 ms
112,660 KB
testcase_18 AC 201 ms
80,744 KB
testcase_19 AC 252 ms
113,400 KB
testcase_20 AC 200 ms
81,028 KB
testcase_21 AC 206 ms
80,688 KB
testcase_22 AC 199 ms
80,648 KB
testcase_23 AC 197 ms
81,072 KB
testcase_24 AC 240 ms
112,100 KB
testcase_25 AC 198 ms
80,804 KB
testcase_26 AC 197 ms
80,952 KB
testcase_27 AC 205 ms
80,844 KB
testcase_28 AC 207 ms
80,964 KB
testcase_29 AC 201 ms
80,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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))

0