結果

問題 No.710 チーム戦
ユーザー silversmithsilversmith
提出日時 2018-11-01 23:59:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 744 bytes
コンパイル時間 353 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 386,460 KB
最終ジャッジ日時 2024-04-30 12:23:09
合計ジャッジ時間 4,902 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
17,820 KB
testcase_01 AC 54 ms
14,952 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A_B=[input().split(" ") for i in range(N)]
#A[i]:i+1の問題をAが解く時間
A=[int(x[0]) for x in A_B]
#B[i]:i+1の問題をBが解く時間
B=[int(x[1]) for x in A_B]

#dp[(i,j)]:i番目までの問題で、Aがj秒以下問題を解くという条件の下でBが解かないでよい時間の最大値
dp={}
for j in range(sum(A)):
	dp[(0,j)]=0

for i in range(N):
	for j in range(sum(A)):
		#jが小さく、i+1番目の問題が解けない場合
		if j < A[i]:
			dp[(i+1,j)]=dp[(i,j)]
		else:
			#i+1の問題をAが解ける場合、i+1の問題はAが解くかとかないかの2通り
			dp[(i+1,j)]=max(dp[(i,j)],dp[(i,j - A[i])] + B[i])

sum_B=sum(B)
print(min([max(a,sum_B - dp[(N,a)]) for a in range(sum(A))]))
0