Submission #917302

#TimeUsernameProblemLanguageResultExecution timeMemory
917302406Feast (NOI19_feast)C++17
22 / 100
39 ms5564 KiB
#include <bits/stdc++.h> #define int long long #define FOR(i, a, b) for (int i = (a); i < (b); ++i) using namespace std; using ar = array<int, 2>; const int64_t INF = 1ll << 60; const int N = 3e5 + 5; int n, k, mx[N]; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> k; int s = 0, id = 0; FOR(i, 0, n) { int a; cin >> a; s += a; if (s < 0) { id = i + 1; s = 0; } mx[id] = max(mx[id], s); } sort(mx, mx + N, greater<>()); int ans = 0; FOR(i, 0, k) ans += max(mx[i], 0ll); cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...