Skip to content

Commit 31afb9f

Browse files
authored
Add files via upload
1 parent 66f62f9 commit 31afb9f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef vector<int> vi;
8+
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
9+
/* -----------------------------------------------------------------------------------*/
10+
11+
int main()
12+
{
13+
pan;
14+
int n;
15+
cin>>n;
16+
vi v(n,0);
17+
for(auto &s:v)
18+
cin>>s;
19+
int best=0,maxo=0;
20+
for(int i=0;i<n;i++)
21+
{
22+
maxo=max(maxo+v[i],v[i]);
23+
best=max(best,maxo);
24+
}
25+
cout<<"maximum subarray is "<<best<<endl;
26+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy