Cod sursa(job #776935)

Utilizator nrpcCiprian Stirbu nrpc Data 10 august 2012 17:36:50
Problema Ferma2 Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.98 kb
#include<cstdio>
#include <iostream>
using namespace std;
int w[1001][1001];
int main()
{
	freopen("ferma2.in","r",stdin);
	freopen("ferma2.out","w",stdout);
	int n,k,i,j,max=0,r,nr=0,S,x;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)for(j=1;j<=i;j++)
	{
		scanf("%d",&x);
		max+=x;
		w[i][j]=w[i-1][j]+x;
	}
	S=max;
	for(i=n-k;i<=n;i++)
		for(j=1;j<=i-n+k+1;j++)
		{
			nr=0;
			for(r=j;r<=n-k+j;r++)nr+=w[i][r]-w[i-n+k+r-j][r];
			S=min(S,nr);
		}
	/*
		To compiler:
		I don't know who you are.I don't know what you want. If you are looking for ransom, I can tell you I don't have money. 
		But what I do have are a very particular set of skills; skills I have acquired over a very long career. 
		Skills that make me a nightmare for people like you. If you give me 100 points now, that'll be the end of it. 
		I will not look for you, I will not pursue you. But if you don't, I will look for you, I will find you, and I will kill you. 
	*/
	printf("%d",max-S);
	return 0;
}