結果

問題 No.545 ママの大事な二人の子供
ユーザー sue_charosue_charo
提出日時 2017-07-14 23:02:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 930 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 16,896 KB
最終ジャッジ日時 2024-04-16 20:38:57
合計ジャッジ時間 7,189 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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):
    def plus(now_ind=0, sum_a=0, sum_b=0):
        if now_ind == n:
            return abs(sum_a - sum_b)
        dif_a = plus(now_ind + 1, sum_a + A[now_ind], sum_b)
        dif_b = plus(now_ind + 1, sum_a, sum_b + B[now_ind])

        return min(dif_a, dif_b)

    ans = plus()
    return ans


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


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