MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / main

Function main

CSES/Sorting/MaximumSubarraySum.cc:7–21  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#define int long long
6
7int32_t main(){
8 ios_base::sync_with_stdio(false),cin.tie(nullptr);
9
10 int ans = -1e10;
11 int curr = 0;
12 int n; cin >> n;
13 vector<int> v(n);
14 rep(i,0,n) cin >> v[i];
15 rep(i,0,n) {
16 curr = max(v[i], curr + v[i]);
17 ans = max(ans, curr);
18 }
19 cout << ans << endl;
20 return 0;
21}
22
23

Callers

nothing calls this directly

Calls 1

maxFunction · 0.50

Tested by

no test coverage detected