Pagini recente » Cod sursa (job #2185877) | Cod sursa (job #40376) | Cod sursa (job #2291866) | Cod sursa (job #291195) | Cod sursa (job #2044652)
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream in ("submat.in");
ofstream out ("submat.out");
int n,i,j,v[1500],m,x,im,ima,s=0,ma,mi;
int main()
{
ma=0;
mi=99999;
in>>n;
for(i=1;i<=n;i++)
{in>>x;
s=s+x;
cout<<s<<" ";
if(s<mi){mi=s;im=i;}
if(s>ma){ma=s;ima=i;}
}
out<<ma-mi<<" ";
out<<im+1<<" "<<ima;
return 0;
}