Pagini recente » Cod sursa (job #2663050) | Cod sursa (job #2942130) | Cod sursa (job #607396) | Cod sursa (job #2551757) | Cod sursa (job #3186250)
#include <bits/stdc++.h>
#define MAX 305
using namespace std;
ifstream fin("teren.in");
ofstream fout("teren.out");
int n, m, k, armax;
int y, sp[MAX+1][MAX+1];
int main()
{
fin >> n >> m >> k;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
{
fin >> y;
sp[i][j]=sp[i-1][j]+y;
}
}
for(int l=1; l<=n; l++)
{
for(int p=l+1; p<=n; p++)
{
int st = 1;
int dr = 1;
int sum = sp[p][1]-sp[l-1][1];
while(st<=m && dr<=m)
{
if(sum>k)
sum-=sp[p][st]-sp[l-1][st++];
else
{
armax = max(armax,(p-l+1)*(dr-st+1));
sum+=sp[p][++dr]-sp[l-1][dr];
}
}
}
}
fout << armax;
return 0;
}