diff --git a/Luogu/P1115/P1115.cpp b/Luogu/P1115/P1115.cpp new file mode 100644 index 00000000..4b6b3c35 --- /dev/null +++ b/Luogu/P1115/P1115.cpp @@ -0,0 +1,24 @@ +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 2e5 + 5; + +int n, f[N], ans = std::numeric_limits::min(); + +int main() { + std::ios::sync_with_stdio(false); + + cin >> n; + for (int i = 1, x; i <= n; i++) { + cin >> x; + f[i] = std::max(f[i - 1] + x, x); + ans = std::max(ans, f[i]); + } + cout << ans << endl; + + return 0; +}