This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |