Cod sursa(job #2489148)

Utilizator tomaionutIDorando tomaionut Data 7 noiembrie 2019 22:46:01
Problema Teren Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <bits/stdc++.h>

using namespace std;
ifstream fin("teren.in");
ofstream fout("teren.out");
int a[305][305],n,m,k,M;
int main()
{
    int i,j,st,dr,x;
    fin >> n >> m >> k;
    for (i=1; i<=n; i++)
        for (j=1; j<=m; j++)
        {
    fin >> x;
    a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1]+x;
        }
    for (i=1; i<=n; i++)
    for (j=i; j<=n; j++)
    {
        st=1;
        dr=1;
        while (st<=m)
        {
            while (dr<=m && a[j][dr]-a[i-1][dr]-a[j][st-1]+a[i-1][st-1]<=k)
                dr++;
            dr--;
            M=max(M,(j-i+1)*(dr-st+1));
            st++;
        }

    }
    fout << M;



    return 0;
}