結果
| 問題 |
No.545 ママの大事な二人の子供
|
| コンテスト | |
| ユーザー |
sue_charo
|
| 提出日時 | 2017-07-14 23:02:24 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 930 bytes |
| コンパイル時間 | 228 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 16,768 KB |
| 最終ジャッジ日時 | 2024-10-07 23:47:52 |
| 合計ジャッジ時間 | 7,282 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 TLE * 2 -- * 12 |
ソースコード
# 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()
sue_charo