제출 #633132

#제출 시각아이디문제언어결과실행 시간메모리
633132hfoliacotsKnapsack (NOI18_knapsack)C++14
0 / 100
1091 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) continue; cout << a[i][2] << ' ' << a[i][1] << ' ' << a[i][0] << endl; 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...