結果

問題 No.2232 Miser's Gift
ユーザー syun0713syun0713
提出日時 2023-03-03 21:45:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 1,353 bytes
コンパイル時間 2,381 ms
コンパイル使用メモリ 206,224 KB
実行使用メモリ 42,956 KB
最終ジャッジ日時 2023-10-18 01:42:09
合計ジャッジ時間 11,021 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 184 ms
42,956 KB
testcase_04 AC 184 ms
42,956 KB
testcase_05 AC 20 ms
7,316 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 127 ms
4,348 KB
testcase_08 AC 182 ms
42,956 KB
testcase_09 AC 185 ms
42,956 KB
testcase_10 AC 187 ms
42,956 KB
testcase_11 AC 185 ms
42,956 KB
testcase_12 AC 184 ms
42,956 KB
testcase_13 AC 184 ms
42,956 KB
testcase_14 AC 184 ms
42,956 KB
testcase_15 AC 184 ms
42,956 KB
testcase_16 AC 184 ms
42,956 KB
testcase_17 AC 182 ms
42,956 KB
testcase_18 AC 184 ms
42,956 KB
testcase_19 AC 183 ms
42,956 KB
testcase_20 AC 185 ms
42,956 KB
testcase_21 AC 183 ms
42,956 KB
testcase_22 AC 182 ms
42,956 KB
testcase_23 AC 184 ms
42,956 KB
testcase_24 AC 184 ms
42,956 KB
testcase_25 AC 183 ms
42,956 KB
testcase_26 AC 184 ms
42,956 KB
testcase_27 AC 184 ms
42,956 KB
testcase_28 AC 184 ms
42,956 KB
testcase_29 AC 184 ms
42,956 KB
testcase_30 AC 183 ms
42,956 KB
testcase_31 AC 182 ms
42,956 KB
testcase_32 AC 183 ms
42,956 KB
testcase_33 AC 183 ms
42,956 KB
testcase_34 AC 186 ms
42,956 KB
testcase_35 AC 184 ms
42,956 KB
testcase_36 AC 183 ms
42,956 KB
testcase_37 AC 186 ms
42,956 KB
testcase_38 AC 3 ms
4,348 KB
testcase_39 AC 4 ms
4,348 KB
testcase_40 AC 4 ms
4,348 KB
testcase_41 AC 4 ms
4,348 KB
testcase_42 AC 4 ms
4,348 KB
testcase_43 AC 4 ms
4,348 KB
testcase_44 AC 3 ms
4,348 KB
testcase_45 AC 4 ms
4,348 KB
testcase_46 AC 4 ms
4,348 KB
testcase_47 AC 4 ms
4,348 KB
testcase_48 AC 2 ms
4,348 KB
testcase_49 AC 2 ms
4,348 KB
testcase_50 AC 3 ms
4,348 KB
testcase_51 AC 2 ms
4,348 KB
testcase_52 AC 2 ms
4,348 KB
testcase_53 AC 2 ms
4,348 KB
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 2 ms
4,348 KB
testcase_56 AC 2 ms
4,348 KB
testcase_57 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define rp(i,n) rep(i,0,n)
#define all(v) v.begin(), v.end()
#define pb push_back
#define yes {cout<<"Yes"; return 0;}
#define no {cout<<"No"; return 0;}
#define yn(jg){if(jg) yes; no;}
#define Noo {cout<<-1; return 0;}
#define NL {cout<<endl;}
ll mod0 = 998244353;
ll lmax = 9e18;
ll inf = 2e9;//2147483647
double pi = 3.14159265358979;
//cout<<setprecision(15)<<fixed<<
#define aout(a) {for(auto I:a) cout<<I<<" ";cout<<endl;}
#define bout(a) {for(auto J:a) aout(J);cout<<endl;}
int main() {
    int n, ww; cin >> n >> ww;
    vi w(n), v(n); rp(i, n) cin >> w[i] >> v[i];
    vvi dp(n, vi(ww + 10, 0));
    rp(i, n) {
        if (i > 0) {
            rep(j, 1, ww + 10) {
                if (j >= w[i]) dp[i][j] = max(dp[i][j - 1], dp[i - 1][j - w[i]] + v[i]);
                else dp[i][j] = dp[i][j - 1];
                if (i > 0)  dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            }
        }
        else {
            rp(j, ww + 10)if (j >= w[0]) dp[0][j] = v[0];
        }
    }

rep(i, 1, ww + 1) {
    cout << dp[n-1][ww] - dp[n-1][ww - i]+1 << endl;

}
}
0