/ Randle /

记录详情

Time Exceeded


  
# 状态 耗时 内存占用
#1 Accepted 6ms 3.059 MiB
#2 Accepted 5ms 3.055 MiB
#3 Accepted 12ms 3.066 MiB
#4 Accepted 26ms 3.062 MiB
#5 Accepted 910ms 3.055 MiB
#6 Accepted 983ms 3.191 MiB
#7 Time Exceeded ≥1007ms ≥3.051 MiB
#8 Time Exceeded ≥1005ms ≥3.059 MiB
#9 Time Exceeded ≥1006ms ≥3.059 MiB
#10 Time Exceeded ≥1004ms ≥3.055 MiB

代码

#include<bits/stdc++.h>
const int maxn=600;
inline const void read(int &a)
{
	a=0;int b=1;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')b=-1;c=getchar();}
	while(c>='0'&&c<='9')
	{
		a=(a<<1)+(a<<3)+c-'0';
		c=getchar();
	}
	a*=b;
}
inline const void write(int a)
{
	if(a<0){putchar('-');a=-a;}
	if(a>9)write(a/10);
	putchar(a%10+'0');
}
inline const int max(int a,int b)
{
	if(a>b)return a;
	else return b;
}
int n,m,p,s[maxn][maxn],a[maxn][maxn],ans=0;
inline const int get(int xa,int ya,int xb,int yb)
{
	return s[xa][ya]-s[xa][yb]-s[xb][ya]+s[xb][yb];
}
int main()
{
	read(n);read(m);read(p);
	memset(a,0,sizeof(a));
	memset(s,0,sizeof(s));
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)read(a[i][j]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(p-a[i][j]>0)
			{
				int k=a[i][j];
				a[i][j]=p;
				memset(s,0,sizeof(s));
				for(int k=1;k<=n;k++)
					for(int l=1;l<=m;l++)s[k][l]=s[k-1][l]+s[k][l-1]-s[k-1][l-1]+a[k][l];
				for(int k=0;k<=n;k++)
					for(int l=0;l<=m;l++)
						for(int r=k;r<=n;r++)
							for(int q=l;q<=m;q++)ans=max(ans,get(r,q,k,l));
				a[i][j]=k;
			}
		}
	write(ans);
	return 0;
}

信息

递交者
类型
递交
题目
解密游戏 T3
题目数据
下载
语言
C++
递交时间
2017-10-03 13:42:56
评测时间
2017-10-03 13:42:56
评测机
分数
60
总耗时
≥5968ms
峰值内存
≥3.191 MiB