Submission #1108325

#TimeUsernameProblemLanguageResultExecution timeMemory
1108325expert007Knapsack (NOI18_knapsack)C++14
12 / 100
1 ms348 KiB
#include "bits/stdc++.h" using namespace std; #define ull unsigned long long #define int long long const int MOD = 1e9 + 7; void setIO() { cin.tie(0)->sync_with_stdio(0); } void solve() { int s, n; cin >> s >> n; vector<int> v(n), w(n), k(n); for (int i = 0; i < n; i++) { cin >> v[i] >> w[i] >> k[i]; } if (n == 1) { int maxi = 0; for (int i = 1; i <= k[0]; i++) { int total_weight = w[0] * i; int total_value = v[0] * i; if (total_weight <= s) { maxi = max(maxi, total_value); } else { break; } } cout << maxi << endl; } } int32_t main() { setIO(); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...