| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1342193 | minhtien | Knapsack (NOI18_knapsack) | C++20 | 1 ms | 344 KiB |
#include <bits/stdc++.h>
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
using namespace std;
const int N=1e5+6;
const int maxn=2e3+4;
ll s,n;
vector<ll>v[N];
ll dp[N];
ll tong=0;
int main()
{
cin >>s >>n;
for(int i=1;i<=n;i++){
ll x,y,z;
cin >>x >>y >>z;
ll tong=s/y;
while(v[y].size()<tong && z>0){
v[y].push_back(x);
z--;
}
}
for(int i=0;i<=maxn-1;i++){
sort(v[i].begin(),v[i].end(),greater<ll>());
}
for(int w=1;w<=s;w++){
for(int i=0;i<v[w].size();i++){
for(int j=s;j>=0;j--){
if(j>=w){
dp[j]=max(dp[j],dp[j-w]+v[w][i]);
}
}
}
}
for(int j=0;j<=s;j++){
tong=max(tong,dp[j]);
}
cout << tong;
return 0;
}
| # | 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... | ||||
