結果

問題 No.710 チーム戦
ユーザー simamumusimamumu
提出日時 2018-06-30 10:33:36
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 1,525 ms / 3,000 ms
コード長 506 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 9,756 KB
最終ジャッジ日時 2023-09-13 16:15:58
合計ジャッジ時間 23,273 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,796 KB
testcase_01 AC 15 ms
7,836 KB
testcase_02 AC 927 ms
9,080 KB
testcase_03 AC 913 ms
8,996 KB
testcase_04 AC 954 ms
9,068 KB
testcase_05 AC 943 ms
9,080 KB
testcase_06 AC 964 ms
9,216 KB
testcase_07 AC 866 ms
9,016 KB
testcase_08 AC 1,017 ms
8,940 KB
testcase_09 AC 873 ms
9,100 KB
testcase_10 AC 831 ms
9,212 KB
testcase_11 AC 987 ms
9,120 KB
testcase_12 AC 930 ms
8,972 KB
testcase_13 AC 832 ms
9,012 KB
testcase_14 AC 952 ms
9,016 KB
testcase_15 AC 885 ms
9,060 KB
testcase_16 AC 892 ms
8,972 KB
testcase_17 AC 1,037 ms
9,180 KB
testcase_18 AC 948 ms
9,016 KB
testcase_19 AC 990 ms
8,972 KB
testcase_20 AC 906 ms
9,080 KB
testcase_21 AC 962 ms
9,052 KB
testcase_22 AC 1,525 ms
9,756 KB
testcase_23 AC 17 ms
7,836 KB
testcase_24 AC 1,398 ms
9,752 KB
testcase_25 AC 15 ms
7,772 KB
testcase_26 AC 16 ms
7,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

A_li = [0]
B_li = [0]

aa = bb = bsum = 0

for i in range(N):
	a,b = map(int,input().split())
	A_li.append(a)
	B_li.append(b)
	if aa < bb:
		aa += a
	else:
		bb += b
	bsum += b
	
		
ma = max(aa,bb)	+ 1

dp = [0] * ma

for i in range(1,N+1):
	weight = A_li[i]
	value = B_li[i]
	for w in range(ma-1 , weight-1 , -1):
		if dp[w] < dp[w-weight] + value:
			dp[w] = dp[w-weight] + value
	
ans = 10**20	
	
	
for w in range(1,ma):
	ans1 = max(w, (bsum - dp[w]))
	ans = min(ans,ans1)
	
print(ans)
0