제출 #633124

#제출 시각아이디문제언어결과실행 시간메모리
633124hfoliacotsKnapsack (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, v, w, k}; } sort(a.begin(), a.end()); int ans = 0, t = 0, i = 0; while (i < n) { 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...