Submission #1048685

#TimeUsernameProblemLanguageResultExecution timeMemory
1048685tamir1Knapsack (NOI18_knapsack)C++17
0 / 100
1 ms600 KiB
#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 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...