Cod sursa(job #1293659)
| Utilizator | Data | 16 decembrie 2014 12:15:55 | |
|---|---|---|---|
| Problema | Teren | Scor | 80 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.96 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("teren.in");
ofstream fout("teren.out");
short int sc[300][300], n, m, k, b[300];
int main()
{
short int i, j, l, x, s, best=-1;
fin>>n>>m>>k;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
fin>>sc[i][j];
sc[i][j]=sc[i-1][j]+sc[i][j];
}
}
for(i=1;i<=n;i++)
{
for(j=i;j<=n;j++)
{
for(l=1;l<=m;l++)
{
b[l]=sc[j][l]-sc[i-1][l];
}
x=1;
l=1;
s=0;
while(l<=m)
{
while(s+b[l]<=k && l<=m)
{
s+=b[l];
l++;
}
s-=b[x];
if(best<(j-i+1)*(l-x)) best=(j-i+1)*(l-x);
x++;
}
}
}
fout<<best;
return 0;
}
