#爆零 求Hack
  • 板块P1392 取数
  • 楼主杜中坤
  • 当前回复2
  • 已保存回复2
  • 发布时间2021/10/16 21:24
  • 上次更新2023/11/4 03:34:23
查看原帖
#爆零 求Hack
228287
杜中坤楼主2021/10/16 21:24
#include<cstring>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#define int long long
using namespace std;
int n,m,k;
int map[1005][1005];
int now[1005];
int ans=0;
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q;
signed main()
{
	scanf("%lld%lld%lld",&n,&m,&k);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		 scanf("%lld",&now[j]);
		sort(now+1,now+1+m);
		for(int j=1;j<=m;j++)
		map[i][j]=now[j];
		map[i][0]=1;
		ans+=now[1];
		q.push(make_pair(now[2],i));
	}
	printf("%lld ",ans);
	int tt=2;
	while(tt<=k)
	{
		int tmp,num;
		tmp=q.top().second;
		if(map[tmp][0]+1>m){
			q.pop();
			continue;
		}
		ans-=map[tmp][map[tmp][0]];
		num=map[tmp][++map[tmp][0]];
		ans+=num;
		q.pop();
		q.push(make_pair(num,tmp));
		printf("%lld ",ans);
		tt++;
	}
	printf("\n");
	return 0;
}
2021/10/16 21:24
加载中...