結果
| 問題 |
No.2741 Balanced Choice
|
| コンテスト | |
| ユーザー |
おぼ
|
| 提出日時 | 2024-04-21 10:23:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,052 bytes |
| コンパイル時間 | 1,934 ms |
| コンパイル使用メモリ | 181,772 KB |
| 実行使用メモリ | 123,008 KB |
| 最終ジャッジ日時 | 2024-10-13 09:10:52 |
| 合計ジャッジ時間 | 8,202 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | TLE * 1 -- * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(int)(b);i++)
#define ll long long
int main() {
int n, W, D;
cin>>n>>W>>D;
vector<int> t(n),w(n),v(n);
rep(i,0,n) {
cin>>t[i]>>w[i]>>v[i];
}
vector<map<int,int>> dp(W+1);
dp[0][0] = 0;
rep(i,0,n) {
for(int j=W;j>=w[i];j--) {
vector<pair<int,int>> updates;
for(auto &p:dp[j-w[i]]) {
int new_diff = (t[i]==0) ? (p.first+w[i]) : (p.first-w[i]);
updates.push_back({new_diff, p.second+v[i]});
}
for(auto &u:updates) {
if(dp[j].find(u.first)==dp[j].end()||dp[j][u.first]<u.second) {
dp[j][u.first]=u.second;
}
}
}
}
int max_value = 0;
// rep(j,0,W+1) {
// for(auto &p:dp[j]) {
// if(abs(p.first)<=D) {
// max_value=max(max_value,p.second);
// }
// }
// }
cout<<max_value<<endl;
return 0;
}
おぼ