#7RE求助
查看原帖
#7RE求助
278259
RemiliaScar1et楼主2020/6/10 10:45

rt,最后一个点RE

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[500][500];
ll sum[500][500];
ll n,m,c;
int main()
{
	cin>>n>>m>>c;
	for(int i=1;i<=n;i++)
	{
		ll s=0;
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			s=s+a[i][j];
			sum[i][j]=sum[i-1][j]+s;
		}
	}
	ll ans=-1145141919;
	int x,y;
	for(int x1=1;x1<=n-c;x1++)
	{
		for(int y1=1;y1<=m-c;y1++)
		{
			int x2=x1+c-1;
			int y2=y1+c-1;
			if(sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1]>=ans)
			{
				ans=sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1];
				x=x1,y=y1;
			}
		}
	}
	cout<<x<<" "<<y;
	return 0;
}
2020/6/10 10:45
加载中...