| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1288857 | red_souls | Feast (NOI19_feast) | C++20 | 1098 ms | 68936 KiB |
#include <bits/stdc++.h>
#define ll long long
#define task "Feast"
using namespace std;
const int N = 3e5 + 16;
const ll INF = 1e18;
int n, q;
ll a[N];
namespace sub6 {
ll dp[2016][2016], prefix[N], maxx[2016][2016];
void solve() {
for (int i = 1; i <= n; i++) {
prefix[i] = prefix[i - 1] + a[i];
}
for (int k = 1; k <= q; k++) {
for (int i = 1; i <= n; i++) {
maxx[k][i] = max(maxx[k][i - 1], dp[k - 1][i - 1] - prefix[i - 1]);
}
for (int i = 1; i <= n; i++) {
dp[k][i] = max(dp[k][i], dp[k][i - 1]);
dp[k][i] = max(dp[k][i], maxx[k][i] + prefix[i]);
}
}
cout << dp[q][n];
}
}
int main() {
ios_base :: sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
sub6 :: solve();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
