啊?
查看原帖
啊?
696431
lijunxi1楼主2023/5/1 10:18
#include<bits/stdc++.h>
using namespace std;
struct aa
{
	int x,y,g;
	bool operator<(const aa&c)const
	{
		return g<c.g;
	}
}a;
priority_queue<aa>q;
int x,y,m,n,k,g,time123;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			a.x=i;a.y=j;
			cin>>a.g;
			if (a.g!=0)q.push(a);
		 } 
	}
	if (q.empty())
	{
		cout<<0;
		return 0;
	}
	a=q.top();
	q.pop();
	if (2*a.x+1>k)
	{
		cout<<0;
		return 0;
	}
	x=a.x,y=a.y;
	g+=a.g;
	time123+=x+1;
	while (!q.empty())
	{
		a=q.top();
		q.pop(); 
		if(time123+abs(x-a.x)+abs(y-a.y)+a.x+1>k)
		{
			cout<<g;
			return 0;
		 } 
		time123+=abs(x-a.x)+abs(y-a.y)+1;
		x=a.x;
		y=a.y;
		g+=a.g;
	}
	cout<<g;
}

luogu尽然只能RETRUN0?

2023/5/1 10:18
加载中...