結果

問題 No.1570 Blocks
ユーザー shiomusubi496shiomusubi496
提出日時 2021-06-27 14:15:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 640 bytes
コンパイル時間 2,272 ms
コンパイル使用メモリ 203,052 KB
実行使用メモリ 17,824 KB
最終ジャッジ日時 2023-09-07 17:46:49
合計ジャッジ時間 16,394 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 4 ms
5,268 KB
testcase_23 WA -
testcase_24 AC 6 ms
13,612 KB
testcase_25 AC 5 ms
9,688 KB
testcase_26 AC 8 ms
15,652 KB
testcase_27 WA -
testcase_28 AC 7 ms
15,660 KB
testcase_29 AC 5 ms
9,568 KB
testcase_30 WA -
testcase_31 AC 7 ms
13,912 KB
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF=1e18;
struct block{int w,s,v;};
void chmax(int &a,int b){if(a<b)a=b;}
block B[1100];
int dp[1100][20100];
signed main(){
  int N;cin>>N;
  for(int i=0;i<N;i++)cin>>B[i].w>>B[i].s,B[i].v=1;
  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<=20000;j++)dp[i+1][j]=dp[i][j];
    for(int j=0;j+B[i].w<=20000;j++)if(j<=B[i].s)
      chmax(dp[i+1][j+B[i].w],dp[i][j]+B[i].v);
  }
  int ans=-INF;
  for(int i=0;i<=20000;i++)chmax(ans,dp[N][i]);
  puts(ans==N?"Yes":"No");
}
0