Submission #633127

#TimeUsernameProblemLanguageResultExecution timeMemory
633127hfoliacotsKnapsack (NOI18_knapsack)C++14
12 / 100
1 ms212 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, w, v, k}; } sort(a.begin(), a.end()); int ans = 0, t = 0, i = 0; while (i < n) { if (t + a[i][1] > s) break; ans += a[i][2]; t += a[i][1]; 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...