Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
332713 黄浙峰老师 【C6-7】营养膳食 C++ 通过 100 3 MS 256 KB 549 2025-07-15 10:35:15

Tests(10/10):


// 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; }


测评信息: