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 ll long long
using namespace std;
ll n,S,i,res=0;
array<ll,3> p[100001];
bool cmp(array<ll,3> a,array<ll,3> b){
return double(a[0])/a[1]>double(b[0])/b[1];
}
int main(){
cin >> S >> n;
for(i=1;i<=n;i++){
cin >> p[i][0] >> p[i][1] >> p[i][2];
}
sort(p+1,p+n+1,cmp);
for(i=1;i<=n;i++){
if(S>=p[i][1]){
res+=p[i][0];
S-=p[i][1];
}
}
cout << res;
}
# | 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... |