結果

問題 No.710 チーム戦
ユーザー silversmithsilversmith
提出日時 2018-11-02 00:27:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 893 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 314,876 KB
最終ジャッジ日時 2024-04-30 13:23:20
合計ジャッジ時間 54,332 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
17,948 KB
testcase_01 AC 28 ms
11,392 KB
testcase_02 AC 2,800 ms
291,316 KB
testcase_03 AC 2,729 ms
288,472 KB
testcase_04 TLE -
testcase_05 AC 2,267 ms
287,216 KB
testcase_06 TLE -
testcase_07 AC 2,763 ms
290,064 KB
testcase_08 TLE -
testcase_09 AC 2,777 ms
288,392 KB
testcase_10 AC 2,821 ms
292,032 KB
testcase_11 AC 2,871 ms
291,680 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 AC 2,773 ms
290,452 KB
testcase_15 AC 2,996 ms
299,480 KB
testcase_16 TLE -
testcase_17 AC 2,871 ms
291,028 KB
testcase_18 AC 2,956 ms
290,704 KB
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A_B=[input().split(" ") for i in range(N)]
A_B.sort()
#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]

upper_A=sum([A[i] for i in range(N) if A[i]<=B[i]])
upper_B=sum([B[i] for i in range(N) if B[i] <A[i]])

upper_A=max(upper_A,upper_B)

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

for i in range(N):
	for j in range(upper_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(upper_A)]))
0