# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
751747 | VMaksimoski008 | Knapsack (NOI18_knapsack) | C++14 | 1 ms | 212 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
using ll = long long;
using ull = unsigned long long;
const int mod = 1e9 + 7;
const int maxn = 1e6;
using namespace std;
void setUSA(string name)
{
string inName = name + ".in";
string outName = name + ".out";
freopen(inName.c_str(), "r", stdin);
freopen(outName.c_str(), "w", stdout);
}
void setIO(string name = "")
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
if(name != "") setUSA(name);
}
struct Product
{
int val;
int weight;
int copies;
};
int main()
{
setIO();
int s, n;
cin >> s >> n;
vector<Product> v(n);
for(Product &p : v) cin >> p.val >> p.weight >> p.copies;
if(n == 1) {
int w = v[0].weight;
int c = v[0].copies;
int vr = v[0].val;
if(w*c <= s) cout << vr*c << '\n';
else cout << vr * min(s / w, c) << '\n';
return 0;
}
return 0;
}
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... |