Submission #633121

#TimeUsernameProblemLanguageResultExecution timeMemory
633121hfoliacotsKnapsack (NOI18_knapsack)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vd = vector<double>; using vvi = vector<vi>; using vvd = vector<vd>; using ll = long long; int main() { int s, n; cin >> s >> n; vvd a(n, vd(4)); for (int i = 0; i < n; i++) { double v, w, k; cin >> v >> w >> k; a[i] = {w/v, v, w, k}; } sort(a.begin(), a.end()); int ans = 0, t = 0, i = 0; while (t < s) { if (t + a[i][2] > s) break; ans += a[i][1]; t += a[i][2]; a[i][3]--; if (a[i][3] == 0) i++; } cout << ans << endl; }
#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...