| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1075637 | tradz | Holding (COCI20_holding) | C++14 | 103 ms | 204616 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define For(i,a,b) for(int i = a; i <= b; i++)
#define Ford(i,a,b) for(int i = a; i >= b; i--)
#define ll long long
#define ii pair<int,int>
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define RRH(v) v.resize(unique(all(v)) - v.begin())
using namespace std;
const int  N = 1e6+7;
const int M = 1e9+7;
const ll oo = 3e18;
int n, l, r, k;
int a[N];
int dpL[102][102][2507];
int dpR[102][102][2507];
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    #define TASK ""
    if (fopen (".inp", "r")) {
        freopen (".inp", "r", stdin);
        freopen (".out", "w", stdout);
    }
    if(fopen(TASK".inp", "r")) {
        freopen(TASK".inp", "r", stdin);
        freopen(TASK".out", "w", stdout);
    }
    cin >> n >> l >> r >> k;
    memset(dpL, 0, sizeof dpL);
    memset(dpR, 0, sizeof dpR);
    For (i, 1, n) cin >> a[i];
    k = min(k, n * n / 4);
    int sum = 0;
    for (int i = l; i <= r; i++) sum += a[i];
    for (int i = 1; i < l; i++) {
        for (int j = l; j <= r; j++) {
            for (int h = 0; h <= k; h++) {
                dpL[i][j][h] = max(dpL[i - 1][j][h], dpL[i][j - 1][h]);
                if (h >= (j - i)) dpL[i][j][h] = max(dpL[i][j][h], dpL[i - 1][j - 1][h - j + i] + a[j] - a[i]);
            }
        }
    }
    for (int i = n; i > r; i--) {
        for (int j = r; j >= l; j--) {
            for (int h = 0; h <= k; h++) {
                dpR[j][i][h] = max(dpR[j + 1][i][h], dpR[j][i + 1][h]);
                if (h >= (i - j)) dpR[j][i][h] = max(dpR[j][i][h], dpR[j + 1][i + 1][h - i + j] + a[j] - a[i]);
            }
        }
    }
    int ans = 0;
    ans = max(dpL[l - 1][r][k], dpR[l][r + 1][k]);
    for (int i = l; i <= r; i++) {
        for (int h = 0; h <= k; h++) {
            ans = max(ans, dpL[l - 1][i][h] + dpR[i + 1][r + 1][k - h]);
        }
    }
    cout << sum - ans << '\n';
    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... | ||||
