結果
| 問題 |
No.2232 Miser's Gift
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-03 21:31:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 113 ms / 2,000 ms |
| コード長 | 599 bytes |
| コンパイル時間 | 4,198 ms |
| コンパイル使用メモリ | 253,312 KB |
| 最終ジャッジ日時 | 2025-02-11 01:51:24 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 55 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
using P = pair<ll,ll>;
vector<P> vpii;
int n,w;
ll dp[101][101010];
void solve(){
for(int i =0;i<n;i++){
auto [wi,vi] = vpii[i];
for(int j = 0;j<=w;j++){
dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
if(j-wi>=0)
dp[i+1][j] = max(dp[i+1][j],dp[i][j-wi]+vi);
}
}
for(int i = w-1;i>=0;i--){
cout<<dp[n][w]-dp[n][i]+1<<'\n';
}
}
signed main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
cin >> n >> w;
vpii.resize(n);
for(auto &[l,r]:vpii)cin>>l>>r;
solve();
}