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>
#define sts(v) stable_sort(v.BE, v.E)
#define Rsts(v) stable_sort(v.rBE, v.rE)
#define rev(v) reverse(v.BE, v.E)
#define BE begin()
#define rBE rbegin()
#define E end()
#define rE rend()
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define F first
#define S second
using namespace std;
using ll = long long;
struct datos{
int val, w, k;
};
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int W, n; cin >> W >> n;
vector<pair<pair<double, int>, pair<int, int>>> v(n);
for(int i = 0; i < n; i++){
int val, w, k; cin >> val >> w >> k;
v[i] = {
{val / w, val},
{w, k}
};
}
Rsts(v);
ll ans = 0, w = 0;
for(auto &i : v){
while(w + i.S.F <= W && i.S.S--){
w += i.S.F;
ans += i.F.S;
}
}
cout << ans;
return 0;
}
# | 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... |