Cod sursa(job #18666)

Utilizator luana_0105Fagarasan Luana luana_0105 Data 18 februarie 2007 12:56:35
Problema Plantatie Scor 0
Compilator cpp Status done
Runda preONI 2007, Runda 2, Clasa a 10-a Marime 0.56 kb
#include<stdio.h>



FILE *f,*g;

int huge a[501][501];

int n;
long m;
long max;
int main()
{

	int i,j,p,k,x,y;
	f=fopen("plantatie.in","r");
	g=fopen("plantatie.out","w");
	fscanf(f,"%d",&n);
	fscanf(f,"%ld",&m);

	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			fscanf(f,"%ld",&a[i][j]);

	for(p=1;p<=m;p++)
	{
		fscanf(f,"%d",&x);
		fscanf(f,"%d",&y);
		fscanf(f,"%d",&k);
		max=0;
		for(int c=x;c<x+k;c++)
			for(int d=y;d<y+k;d++)
				if(a[c][d]>max)
					max=a[c][d];
		fprintf(g,"%ld\n",max);
	}
	fcloseall();
	return 0;

}