Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n,i,j,maxx=-INT_MAX,maxj=1,maxi=0,k;
- cin >> n;int a[n];fill(a,a+n,0);cin >> a[1];cout << a[1] << " ";
- for (i=2;i<=n;i++)
- {
- cin >> k;
- a[i]=a[i-1]+k;
- cout << a[i] << " ";
- }
- cout << endl;
- for (i=1;i<n;i++)
- {
- for (j=i;j<=n;j++)
- {
- cout << maxx << endl;
- // cout << i << " " << j << " " << a[j] << " " << a[i] << " " << a[j]-a[i] << endl;
- if (a[j]-a[i]>maxx) {maxx = a[j]-a[i]; maxj=j;maxi=i;}
- }
- }
- cout << maxi << " " << maxj;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement