#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "local_debug.cpp"
#else
#define debug(...)
#define debugArr(...)
#endif
#define int long long
#define nl '\n'
#define sp ' '
#define F first
#define S second
#define SZ(s) (int)((s).size())
const int N = 3e5 + 5;
int a[N], dp[N];
void solve() {
int n, k; cin >> n >> k;
for(int i = 0; i < n; ++i) cin >> a[i];
for(int i = 1; i <= n; ++i) dp[i] = max(dp[i - 1] + a[i - 1], a[i - 1]);
int ans = 0;
for(int i = 1; i <= n; ++i) ans = max(ans, dp[i]);
cout << ans << nl;
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int tc = 1;
// cin >> tc;
while(tc--) solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |