Cod sursa(job #19397)

Utilizator plastikDan George Filimon plastik Data 19 februarie 2007 14:11:13
Problema Plantatie Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 kb
#include <fstream>
#include <iostream>
using namespace std;

const int MAX_N = 512;
int N, M;
int A[MAX_N][MAX_N];

int main(void) {
	fstream in("plantatie.in", ios::in);
	fstream out("plantatie.out", ios::out);
	in >> N >> M;
	int i, j;
	for (i = 0; i < N; ++ i) {
		for (j = 0; j < N; ++ j) {
			in >> A[i][j];
		}
	}
	int t, nc, is, js;
	for (t = 0; t < M; ++ t) {
		int max = 0;
		in >> is >> js >> nc;
		is --;
		js --;
		for (i = is; i < is + nc; ++ i) {
			for (j = js; j < js + nc; ++ j) {
				if (max < A[i][j]) {
					max = A[i][j];
				}
			}
		}
		out << max << "\n";
	}

	return 0;
}