提交时间:2025-07-15 10:35:15
运行 ID: 332713
// 756 - 【C6-7】营养膳食 #include<bits/stdc++.h> using namespace std; int ma[110]; struct food{ int fat,type; }f[210]; bool cmp(food a, food b){ return a.fat > b.fat; } int main(){ int n,m,k,s=0; cin>>n>>m>>k; for(int i=1; i<=k; i++){ cin>>ma[i]; } for(int i=1; i<=n; i++){ cin>>f[i].fat>>f[i].type; } sort(f+1, f+n+1,cmp); for(int i=1; i<=n; i++){ if(m==0) break; if(ma[f[i].type]){ if(ma[f[i].type] && m){ m--; s+=f[i].fat; ma[f[i].type]--; } } } cout<<s; return 0; }