이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define nl "\n"
#define nf endl
#define ll long long
#define pb push_back
#define _ << ' ' <<
#define INF (ll)1e18
#define mod 998244353
#define maxn 110
#define maxm 10010
ll i, i1, j, k, k1, t, n, m, res, flag[10], a[maxn], b;
ll l, r, dp[2][maxn][maxm];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #if !ONLINE_JUDGE && !EVAL
        ifstream cin("input.txt");
        ofstream cout("output.txt");
    #endif
    cin >> n >> l >> r >> m;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (i = l; i <= r; i++) {
        for (j = 1; j <= n; j++) {
            for (k = abs(j - i); k <= m; k++) {
                dp[1][j][k] = max(dp[0][j][k], dp[1][j - 1][k]);
                if (j >= l && j <= r) continue;
                dp[1][j][k] = max(dp[1][j][k], dp[0][j - 1][k - abs(j - i)] + a[i] - a[j]);
            }
        }
        for (j = 1; j <= n; j++) {
            for (k = 0; k <= m; k++) {
                dp[0][j][k] = dp[1][j][k];
                dp[1][j][k] = 0;
                // cout << dp[0][j][k] << ' ';
            }
            // cout << nl;
        }
        // cout << nl;
    }
    for (i = l; i <= r; i++) res += a[i];
    res -= dp[0][n][m];
    cout << res << nl;
    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... |