結果

問題 No.710 チーム戦
ユーザー silversmithsilversmith
提出日時 2018-11-02 00:36:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 903 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 355,452 KB
最終ジャッジ日時 2024-04-30 14:33:42
合計ジャッジ時間 11,605 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
17,824 KB
testcase_01 AC 33 ms
11,264 KB
testcase_02 AC 2,780 ms
289,984 KB
testcase_03 AC 2,564 ms
289,208 KB
testcase_04 TLE -
testcase_05 AC 2,635 ms
290,728 KB
testcase_06 TLE -
testcase_07 AC 2,881 ms
302,944 KB
testcase_08 TLE -
testcase_09 AC 2,877 ms
300,496 KB
testcase_10 AC 2,818 ms
292,640 KB
testcase_11 AC 2,921 ms
299,284 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 2,773 ms
294,328 KB
testcase_16 TLE -
testcase_17 AC 2,786 ms
300,692 KB
testcase_18 AC 2,995 ms
307,964 KB
testcase_19 TLE -
testcase_20 AC 2,902 ms
305,564 KB
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]

#貪欲法
greed_A=0
greed_B=0
for i in range(N):
	if greed_A + A[i] < greed_B+B[i]:
		greed_A+=A[i]
	else:
		greed_B+=B[i]

upper_A=max(greed_A,greed_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