记录编号 30752 评测结果 AAAAAAAAAA
题目名称 [USACO Mar08] 挖湖 最终得分 100
用户昵称 GravatarTruth.Cirno 是否通过 通过
代码语言 C++ 运行时间 0.050 s
提交时间 2011-10-31 08:51:27 内存使用 0.26 MiB
显示代码纯文本
#include <cstdio>
using namespace std;

int main(void)
{
	freopen("makelake.in","r",stdin);
	freopen("makelake.out","w",stdout);
	int i,j,k,Ln,Co,water,n,x,y,power,maxhei,total=0,map[101][101];
	scanf("%d %d %d %d",&Ln,&Co,&water,&n);
	for (i=1;i<=Ln;i++)
		for (j=1;j<=Co;j++)
			scanf("%d",&map[i][j]);
	for (k=1;k<=n;k++)
	{
		scanf("%d %d %d",&x,&y,&power);
		maxhei=0;
		for (i=x;i<=x+2&&i<=Ln;i++)
			for (j=y;j<=y+2&&j<=Co;j++)
				if (map[i][j]>maxhei)
					maxhei=map[i][j];
		maxhei-=power;
		for (i=x;i<=x+2&&i<=Ln;i++)
			for (j=y;j<=y+2&&j<=Co;j++)
				if (map[i][j]>maxhei)
					map[i][j]=maxhei;
	}
	for (i=1;i<=Ln;i++)
		for (j=1;j<=Co;j++)
			if (map[i][j]<water)
				total+=water-map[i][j];
	total*=5184;
	printf("%d\n",total);
	fclose(stdin);
	fclose(stdout);
	return(0);
}