Cod sursa(job #3229209)

Utilizator anamaria29sSuditu Ana-Maria anamaria29s Data 14 mai 2024 14:36:15
Problema Plantatie Scor 50
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.78 kb
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

ifstream f("plantatie.in");
ofstream g("plantatie.out");

int main() {
    int N, M;
    f >> N >> M;
    
    vector<vector<int>> productivity(N + 1, vector<int>(N + 1));
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j) {
            f >> productivity[i][j];
        }
    }


    for (int q = 0; q < M; ++q) {
        int i, j, k;
        f >> i >> j >> k;

        int max_productivity = 0;
        for (int x = i; x <= i + k - 1; ++x) {
            for (int y = j; y <= j + k - 1; ++y) {
                max_productivity = max(max_productivity, productivity[x][y]);
            }
        }

        g << max_productivity << endl;
    }

    return 0;
}