sgdf
查看原帖
sgdf
736027
zhouchenrui楼主2024/12/21 18:24
#include<bits/stdc++.h>
using namespace std;
priority_queue<int> q;
int main(){
	
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		int y;
		cin>>y;
		q.push(y);
	}	
	int cnt=0;
	while(m--){
		cnt+=q.top();
		q.pop();
	}
	cout<<cnt;
	return 0;
}
2024/12/21 18:24
加载中...