結果

問題 No.545 ママの大事な二人の子供
ユーザー ckawatakckawatak
提出日時 2019-04-25 23:00:22
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 513 bytes
コンパイル時間 649 ms
コンパイル使用メモリ 82,300 KB
実行使用メモリ 82,736 KB
最終ジャッジ日時 2024-05-01 11:59:35
合計ジャッジ時間 6,449 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
59,532 KB
testcase_01 AC 36 ms
52,820 KB
testcase_02 AC 36 ms
53,744 KB
testcase_03 AC 37 ms
52,460 KB
testcase_04 AC 36 ms
52,236 KB
testcase_05 AC 36 ms
51,812 KB
testcase_06 AC 40 ms
52,248 KB
testcase_07 AC 36 ms
52,184 KB
testcase_08 AC 37 ms
52,132 KB
testcase_09 AC 43 ms
60,900 KB
testcase_10 AC 47 ms
61,280 KB
testcase_11 AC 46 ms
61,448 KB
testcase_12 AC 47 ms
61,832 KB
testcase_13 AC 53 ms
63,780 KB
testcase_14 AC 61 ms
65,704 KB
testcase_15 AC 50 ms
63,148 KB
testcase_16 AC 69 ms
66,024 KB
testcase_17 AC 113 ms
75,772 KB
testcase_18 AC 1,167 ms
76,032 KB
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 #

N = int(input())
A = []
B = []
for _ in range(N):
    pair = list(map(int, input().split()))
    A.append(pair[0])
    B.append(pair[1])

mindiff = float('inf')
for i in range(1<<N):
    a1 = 0
    a2 = 0
    b1 = 0
    b2 = 0
    for j in range(N):
        if i & (1 << j):
            a1 = a1 + A[j]
            b2 = b2 + B[j]
        else:
            a2 = a2 + A[j]
            b1 = b1 + B[j]
    diff1 = abs(a1 - b1)
    diff2 = abs(a2 - b2)
    mindiff = min(mindiff, min(diff1, diff2))

print(mindiff)    
0