結果

問題 No.1583 Building Blocks
ユーザー the-xinthe-xin
提出日時 2021-07-03 14:09:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 648 bytes
コンパイル時間 583 ms
コンパイル使用メモリ 70,952 KB
実行使用メモリ 74,496 KB
最終ジャッジ日時 2023-10-12 03:05:13
合計ジャッジ時間 3,698 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
74,232 KB
testcase_01 AC 21 ms
74,212 KB
testcase_02 AC 21 ms
74,252 KB
testcase_03 AC 22 ms
74,216 KB
testcase_04 AC 21 ms
74,200 KB
testcase_05 AC 21 ms
74,284 KB
testcase_06 AC 30 ms
74,372 KB
testcase_07 AC 22 ms
74,208 KB
testcase_08 AC 21 ms
74,140 KB
testcase_09 AC 23 ms
74,176 KB
testcase_10 AC 21 ms
74,236 KB
testcase_11 AC 21 ms
74,164 KB
testcase_12 AC 22 ms
74,176 KB
testcase_13 AC 22 ms
74,464 KB
testcase_14 AC 22 ms
74,188 KB
testcase_15 AC 21 ms
74,376 KB
testcase_16 AC 22 ms
74,204 KB
testcase_17 AC 22 ms
74,320 KB
testcase_18 AC 21 ms
74,140 KB
testcase_19 AC 23 ms
74,384 KB
testcase_20 AC 22 ms
74,208 KB
testcase_21 AC 22 ms
74,196 KB
testcase_22 AC 22 ms
74,172 KB
testcase_23 AC 22 ms
74,280 KB
testcase_24 AC 22 ms
74,264 KB
testcase_25 AC 21 ms
74,232 KB
testcase_26 AC 23 ms
74,224 KB
testcase_27 AC 22 ms
74,200 KB
testcase_28 AC 23 ms
74,156 KB
testcase_29 AC 21 ms
74,232 KB
testcase_30 AC 22 ms
74,236 KB
testcase_31 AC 23 ms
74,148 KB
testcase_32 AC 22 ms
74,376 KB
testcase_33 AC 23 ms
74,280 KB
testcase_34 AC 22 ms
74,368 KB
testcase_35 AC 22 ms
74,380 KB
testcase_36 AC 22 ms
74,196 KB
testcase_37 AC 22 ms
74,236 KB
testcase_38 AC 21 ms
74,188 KB
testcase_39 AC 21 ms
74,244 KB
testcase_40 AC 22 ms
74,252 KB
testcase_41 AC 23 ms
74,448 KB
testcase_42 AC 21 ms
74,140 KB
testcase_43 AC 22 ms
74,280 KB
testcase_44 AC 22 ms
74,212 KB
testcase_45 AC 22 ms
74,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N = 3e3+10,mod = 1e9+7;
LL f[N][N];
struct Node{
	LL a,b;
	bool operator<(const Node &A)const{
		return a+b<A.a+A.b;
	}
}a[N];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].a,&a[i].b);
	}
	sort(a+1,a+1+n);
	memset(f,0x3f,sizeof f);
	f[0][0]=0;
	LL INF = f[1][1];
	int ans=0;
	for(int i=1;i<=n;i++){
		f[i][0]=0;
		for(int j=1;j<=i;j++){
			f[i][j]=min(f[i-1][j],f[i][j]);
			if(a[i].b>=f[i-1][j-1]){
				f[i][j]=min(f[i][j],f[i-1][j-1]+a[i].a);
				ans=max(ans,j);
			}
		}
	}
	cout<<ans;
	return 0;
}
0