結果
問題 | No.1583 Building Blocks |
ユーザー | shiomusubi496 |
提出日時 | 2021-07-02 22:40:27 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 617 bytes |
コンパイル時間 | 2,321 ms |
コンパイル使用メモリ | 201,736 KB |
実行使用メモリ | 12,208 KB |
最終ジャッジ日時 | 2023-09-11 23:01:40 |
合計ジャッジ時間 | 3,837 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 2 ms
4,376 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 3 ms
5,340 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 6 ms
11,704 KB |
testcase_25 | AC | 2 ms
4,380 KB |
testcase_26 | AC | 6 ms
11,528 KB |
testcase_27 | AC | 5 ms
7,420 KB |
testcase_28 | WA | - |
testcase_29 | AC | 4 ms
7,516 KB |
testcase_30 | AC | 2 ms
4,616 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 2 ms
4,376 KB |
testcase_35 | AC | 5 ms
9,516 KB |
testcase_36 | WA | - |
testcase_37 | AC | 4 ms
5,136 KB |
testcase_38 | AC | 1 ms
4,380 KB |
testcase_39 | AC | 2 ms
4,376 KB |
testcase_40 | AC | 2 ms
4,376 KB |
testcase_41 | AC | 2 ms
4,376 KB |
testcase_42 | AC | 2 ms
4,376 KB |
testcase_43 | AC | 1 ms
4,376 KB |
testcase_44 | WA | - |
ソースコード
#include<bits/stdc++.h> #define int long long using namespace std; const int INF=1e18; struct block{int w,s;}; void chmax(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)chmax(dp[i+1][j+1],dp[i][j]+B[i].w); } } for(int i=N;i>0;i--){ if(dp[N][i]>=0)return cout<<i<<endl,0; } cout<<0<<endl; }