結果

問題 No.178 美しいWhitespace (1)
ユーザー _KingdomOfMoray
提出日時 2019-11-24 11:07:30
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 550 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-10-12 04:16:42
合計ジャッジ時間 1,826 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = []
b = []
for i in range(n):
    ai,bi=[int(i) for i in input().split()]
    a.append(ai)
    b.append(bi)
    
def max(a, b):
    if a >= b:
        return a
    else:
        return b
    
res = 0
target = a[0] + 4*b[0]
for i in range(n):
    if i == 0:
        continue
    cur = a[i] + 4*b[i]
    
    if (target - cur) % 2 == 0:
        target = max(target, cur)
    else:
        res = -1
        break

if res == -1:
    print(res)
else:
    for i in range(n):
        res += target - (a[i] + 4*b[i])
    print(int(res/2))
0