結果

問題 No.178 美しいWhitespace (1)
ユーザー mokrai
提出日時 2017-11-16 18:58:39
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 701 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-25 06:37:36
合計ジャッジ時間 1,500 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def main():
    N = int(input())
    spaces_list = []
    odd = False
    even = False
    for i in range(N):
        space, tab = map(int, input().split())
        spaces = space + 4 * tab
        if spaces % 2 == 0:
            even = True
        else:
            odd = True

        if odd and even:
            print(-1)
            sys.exit()
        spaces_list.append(spaces)
    #print(spaces_list)

    if len(set(spaces_list)) == 1:
        print(0)
        sys.exit()

    max_spaces = max(spaces_list)
    needed_spaces = 0
    for spaces in spaces_list:
        needed_spaces += max_spaces - spaces

    print(int(needed_spaces / 2))


if __name__ == '__main__':
    main()
0