Pagini recente » Cod sursa (job #3199784) | Cod sursa (job #1890617) | Cod sursa (job #87616) | Cod sursa (job #2440563) | Cod sursa (job #1126837)
#include <fstream>
#include <vector>
using namespace std;
ifstream f("ssm.in");
ofstream g("ssm.out");
int n,a,b,i,j,x;
int max1;
int sum[600000];
int main()
{ f>>n;
for(i=1;i<=n;i++) {f>>x;sum[i]=sum[i-1]+x;}
for(i=1;i<=n;i++)
for(j=1;j<i;j++) if(sum[i]-sum[j]>max1) {max1=sum[i]-sum[j];a=j+1;b=i;}
g<<max1<<' '<<a<<" "<<b>>'\n';
f.close();
g.close();
return 0;
}