이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
o((>ω< ))o
o(≧口≦)o
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define int ll
#define F first
#define S second
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
//#define endl "\n"
struct mrbeast{
int v; int w; int k;
};
struct roblox{
int w; int v;
};
void solve(){
int S,n,m;
cin >> S >> n;
vector<mrbeast> a_(1e5+10);
vector<roblox> a(3000);
vector<vector<int>> dp(3000,vector<int>(2005));
for (int i = 1; i <= n; i++) cin >> a_[i].v >> a_[i].w >> a_[i].k;
m = 0;
for (int i = 1; i <= n; i++){
for (int j = 0; (1 << j) <= a_[i].k; j++){
a[++m].w = a_[i].w*(1<<j);
a[m].v = a_[i].v*(1<<j);
}
}
// cout << endl;
// for (int i = 1; i <= m; i++) cout << a[i].w << ' ' << a[i].v << endl;
for (int i = 1; i <= n; i++){
for (int j = 0; j <= S; j++){
dp[i][j] = dp[i-1][j];
if (a[i].w < j){
dp[i][j] = max(dp[i-1][j],dp[i-1][j-a[i].w]+a[i].v);
}
}
}
cout << dp[n][S] << endl;
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// int t; cin >> t; while (t--)
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |