結果

問題 No.710 チーム戦
ユーザー silversmithsilversmith
提出日時 2018-11-02 00:11:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 884 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 307,020 KB
最終ジャッジ日時 2024-04-30 12:57:51
合計ジャッジ時間 11,444 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
17,952 KB
testcase_01 AC 32 ms
11,392 KB
testcase_02 AC 2,719 ms
288,628 KB
testcase_03 AC 2,606 ms
289,484 KB
testcase_04 TLE -
testcase_05 AC 2,368 ms
287,848 KB
testcase_06 TLE -
testcase_07 AC 2,802 ms
290,644 KB
testcase_08 TLE -
testcase_09 AC 2,704 ms
288,272 KB
testcase_10 AC 2,768 ms
292,456 KB
testcase_11 AC 2,791 ms
291,084 KB
testcase_12 TLE -
testcase_13 AC 2,887 ms
299,224 KB
testcase_14 AC 2,657 ms
290,732 KB
testcase_15 AC 2,868 ms
300,420 KB
testcase_16 TLE -
testcase_17 AC 2,736 ms
295,440 KB
testcase_18 AC 2,907 ms
293,604 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[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