| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1344807 | hojiakbar2011 | Knapsack (NOI18_knapsack) | C++20 | 1094 ms | 448 KiB |
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ll long long
#define int long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define mp make_pair
void setIO(string s = "") {
ios::sync_with_stdio(false);
cin.tie(nullptr);
if (!s.empty()) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
}
void solve() {
}
signed main() {
setIO(); // or setIO("file")
ll s, n;
cin>>s>>n;
vector<ll> dp(s+1, 0);
while(n--){
ll v, w, k;
cin>>v>>w>>k;
k=min(k, s/w);
while(k--){
for(int i=s;i>=w;i--){
dp[i]=max(dp[i], dp[i-w]+v);
}
}
}
cout<<dp[s];
}Compilation message (stderr)
| # | 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... | ||||
