제출 #1340466

#제출 시각아이디문제언어결과실행 시간메모리
1340466iamhereforfunFeast (NOI19_feast)C++20
21 / 100
4 ms1092 KiB
// Starcraft 2 enjoyer //

#include <bits/stdc++.h>

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

using namespace std;

#define LSOne(X) ((X) & -(X))

const int N = 3e2 + 5;
const int M = 2e5 + 5;
const int LG = 20;
const int INF = 1e9 + 5;
const int K = 2;
const int C = 26;
const int B = 1000;
const int MOD = 998244353;

long long n, k, a[N], pref[N], dp[N][N];
long long ans, cur;

inline void solve()
{
    cin >> n >> k;
    ans = 0;
    cur = 0;
    for (int x = 1; x <= n; x++)
    {
        cin >> a[x];
        pref[x] = pref[x - 1] + a[x];
    }
    dp[0][0] = 0;
    for (int x = 1; x <= n; x++)
    {
        for (int y = 0; y < x; y++)
        {
            for (int z = 1; z <= k; z++)
            {
                dp[x][z] = max(dp[y][z - 1] + pref[x] - pref[y], dp[x][z]);
            }
            for (int z = 0; z <= k; z++)
            {
                dp[x][z] = max(dp[x][z], dp[x - 1][z]);
            }
        }
    }
    for (int x = 0; x <= k; x++)
        ans = max(ans, dp[n][x]);
    cout << ans << "\n";
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    for (int x = 1; x <= t; x++)
    {
        solve();
    }
    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...