結果

問題 No.2232 Miser's Gift
ユーザー syun0713syun0713
提出日時 2023-03-03 21:42:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,364 bytes
コンパイル時間 4,298 ms
コンパイル使用メモリ 206,264 KB
実行使用メモリ 47,264 KB
最終ジャッジ日時 2023-10-18 01:38:54
合計ジャッジ時間 6,506 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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) {
        rep(j,1, ww + 10) {
            if (i > 0) {
                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