| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1329396 | jochis | Feast (NOI19_feast) | C++20 | 1095 ms | 5816 KiB |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, k;
cin >> n >> k;
vector<long long> a(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
const long long NEG_INF = LLONG_MIN / 2;
vector<long long> f(k + 1, 0);
vector<long long> g(k + 1, NEG_INF);
for (int i = 1; i <= n; i++) {
vector<long long> f_prev = f;
for (int j = 1; j <= k; j++) {
long long extend = (g[j] == NEG_INF) ? NEG_INF : g[j] + a[i];
long long start = (f_prev[j-1] == NEG_INF) ? NEG_INF : f_prev[j-1] + a[i];
g[j] = max(extend, start);
f[j] = max(f_prev[j], g[j]);
}
}
cout << f[k] << endl;
return 0;
}| # | 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... | ||||
