結果

問題 No.1583 Building Blocks
ユーザー shiomusubi496shiomusubi496
提出日時 2021-07-02 22:50:25
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 620 bytes
コンパイル時間 2,102 ms
コンパイル使用メモリ 203,160 KB
実行使用メモリ 12,012 KB
最終ジャッジ日時 2023-10-12 03:04:06
合計ジャッジ時間 3,924 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 5 ms
9,516 KB
testcase_04 AC 3 ms
4,740 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 5 ms
9,512 KB
testcase_07 AC 5 ms
9,460 KB
testcase_08 AC 3 ms
4,476 KB
testcase_09 AC 7 ms
11,512 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 5 ms
9,620 KB
testcase_13 AC 6 ms
11,736 KB
testcase_14 AC 4 ms
7,568 KB
testcase_15 AC 5 ms
9,556 KB
testcase_16 AC 6 ms
11,556 KB
testcase_17 AC 6 ms
9,628 KB
testcase_18 AC 3 ms
5,188 KB
testcase_19 AC 8 ms
12,012 KB
testcase_20 AC 4 ms
7,460 KB
testcase_21 AC 4 ms
7,460 KB
testcase_22 AC 4 ms
7,436 KB
testcase_23 AC 3 ms
4,708 KB
testcase_24 AC 6 ms
11,564 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 7 ms
11,592 KB
testcase_27 AC 4 ms
7,492 KB
testcase_28 AC 7 ms
11,564 KB
testcase_29 AC 4 ms
7,504 KB
testcase_30 AC 3 ms
4,768 KB
testcase_31 AC 6 ms
11,616 KB
testcase_32 AC 4 ms
7,412 KB
testcase_33 AC 8 ms
11,888 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 5 ms
9,616 KB
testcase_36 AC 7 ms
11,568 KB
testcase_37 AC 3 ms
5,280 KB
testcase_38 AC 1 ms
4,348 KB
testcase_39 AC 2 ms
4,348 KB
testcase_40 AC 1 ms
4,352 KB
testcase_41 AC 1 ms
4,348 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 AC 2 ms
4,348 KB
testcase_44 AC 1 ms
4,352 KB
testcase_45 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF=1e18;
struct block{int w,s;};
void chmin(int&a,int b){if(a>b)a=b;}
block B[1100];
int dp[1100][1100];
signed main(){
  int N;cin>>N;
  for(int i=0;i<N;i++)cin>>B[i].w>>B[i].s;
  sort(B,B+N,[](block a,block b){return a.w+a.s<b.w+b.s;});
  fill(dp[0],dp[N+1],INF);
  dp[0][0]=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<=N;j++)dp[i+1][j]=dp[i][j];
    for(int j=0;j<N;j++){
      if(dp[i][j]<=B[i].s)chmin(dp[i+1][j+1],dp[i][j]+B[i].w);
    }
  }
  for(int i=N;i>0;i--){
    if(dp[N][i]<=INF/2)return cout<<i<<endl,0;
  }
  cout<<0<<endl;
}
0