結果

問題 No.1947 質より種類数
ユーザー asaringoasaringo
提出日時 2022-05-20 22:50:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 314 ms / 2,000 ms
コード長 891 bytes
コンパイル時間 1,989 ms
コンパイル使用メモリ 201,972 KB
実行使用メモリ 202,948 KB
最終ジャッジ日時 2023-10-20 13:40:39
合計ジャッジ時間 5,906 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,720 KB
testcase_01 AC 2 ms
5,716 KB
testcase_02 AC 2 ms
5,716 KB
testcase_03 AC 2 ms
5,708 KB
testcase_04 AC 4 ms
6,808 KB
testcase_05 AC 3 ms
6,376 KB
testcase_06 AC 4 ms
6,496 KB
testcase_07 AC 3 ms
6,572 KB
testcase_08 AC 4 ms
6,824 KB
testcase_09 AC 8 ms
10,048 KB
testcase_10 AC 7 ms
8,708 KB
testcase_11 AC 17 ms
15,652 KB
testcase_12 AC 12 ms
12,496 KB
testcase_13 AC 5 ms
8,116 KB
testcase_14 AC 76 ms
60,748 KB
testcase_15 AC 41 ms
33,564 KB
testcase_16 AC 107 ms
86,076 KB
testcase_17 AC 137 ms
110,104 KB
testcase_18 AC 240 ms
192,480 KB
testcase_19 AC 210 ms
168,692 KB
testcase_20 AC 160 ms
127,896 KB
testcase_21 AC 189 ms
150,028 KB
testcase_22 AC 13 ms
13,680 KB
testcase_23 AC 88 ms
70,096 KB
testcase_24 AC 5 ms
7,128 KB
testcase_25 AC 4 ms
6,772 KB
testcase_26 AC 3 ms
6,180 KB
testcase_27 AC 4 ms
6,456 KB
testcase_28 AC 4 ms
6,732 KB
testcase_29 AC 313 ms
202,948 KB
testcase_30 AC 314 ms
202,948 KB
testcase_31 AC 2 ms
5,708 KB
testcase_32 AC 2 ms
5,708 KB
testcase_33 AC 2 ms
5,784 KB
testcase_34 AC 227 ms
202,948 KB
testcase_35 AC 228 ms
202,948 KB
testcase_36 AC 312 ms
202,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std ;
#define fast_input_output ios::sync_with_stdio(false); cin.tie(nullptr);
typedef long long ll ;
typedef long double ld ;
typedef pair<ll,ll> P ;
typedef tuple<ll,ll,ll> TP ;
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
#define bit_count(x) __builtin_popcountll(x)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / gcd(a,b) * b
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define rrep(i,a,b) for(int i = a ; i < b ; i++)
#define endl "\n"

int n , v , c ;
ll V[5050] , W[5050] ;
ll dp[5050][5050] ;

int main(){
    fast_input_output
    cin >> n >> v >> c ;
    rep(i,n) cin >> V[i] >> W[i] ;
    rep(i,n) rep(j,v+1) {
        chmax(dp[i+1][j],dp[i][j]) ;
        if(j+V[i] <= v) chmax(dp[i+1][j+V[i]],dp[i][j]+W[i]+c) ;
        if(j+V[i] <= v) chmax(dp[i+1][j+V[i]],dp[i+1][j]+W[i]) ;
    }
    cout << dp[n][v] << endl ;
}
0