結果

問題 No.545 ママの大事な二人の子供
ユーザー sue_charosue_charo
提出日時 2017-07-14 22:49:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 920 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-04-16 20:37:18
合計ジャッジ時間 2,351 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 38 ms
11,264 KB
testcase_02 AC 38 ms
11,264 KB
testcase_03 AC 39 ms
11,264 KB
testcase_04 AC 40 ms
11,520 KB
testcase_05 AC 38 ms
11,264 KB
testcase_06 WA -
testcase_07 AC 38 ms
11,392 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 38 ms
11,520 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    n = II()
    A, B = [], []
    for __ in range(n):
        a, b = ILI()
        A.append(a)
        B.append(b)
    return n, A, B


def solve(n, A, B):
    now_a = 0
    now_b = 0
    for a, b in zip(A, B):
        next_dif_a = abs(now_a + a - now_b)
        next_dif_b = abs(now_b + b - now_a)
        if next_dif_a >= next_dif_b:
            now_b += b
        else:
            now_a += a

    ans = abs(now_a - now_b)
    return ans


def main():
    params = read()
    print(solve(*params))


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