Submission #868261

# Submission time Handle Problem Language Result Execution time Memory
868261 2023-10-31T01:54:02 Z hungnt Holding (COCI20_holding) C++14
55 / 110
4 ms 26972 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 102;

int n, L, R, k;
int a[102];
int dp[N][1500][N];

void MAX(int &A, int B)
{
    if(A < B) A = B;
}

void sub2(int L)
{
    k = min(k, n * n / 2);
    for(int i = L; i <= R; i++)
        for(int c = 1; c <= k; c++)
            for(int j = 1; j <= L - 1; j++)
                dp[i][c][j] = 0;
    int ans = 0;
    for(int i = L; i <= R; i++)
        for(int j = L - 1; j > 0; j--)
            for(int c = 1; c <= k; c++)
            {
                MAX(dp[i][c][j], dp[i - 1][c][j]);
                MAX(dp[i][c][j], dp[i][c][j + 1]);
                if(c - i + j >= 0)
                {
                    MAX(dp[i][c][j], dp[i - 1][c - i + j][j + 1] + a[i] - a[j]);
                    MAX(dp[i][c][j], dp[i - 1][c - i + j][j]);
//                    cout << i << " " << j << " " << c << " " << dp[i][c][j] << "\n";
                }
                ans = max(ans, dp[i][c][j]);
            }
//    cout <<  ans << "\n";
    for(int i = L; i <= R; i++) ans -= a[i];
    cout << -ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> L >> R >> k;
    for(int i = 1; i <= n; i++) cin >> a[i];
    if(R == n)
    {
        sub2(L);
        return 0;
    }
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 2 ms 10588 KB Output is correct
9 Correct 1 ms 10588 KB Output is correct
10 Correct 2 ms 16728 KB Output is correct
11 Correct 3 ms 18780 KB Output is correct
12 Correct 4 ms 26972 KB Output is correct
13 Correct 4 ms 16732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 2 ms 10588 KB Output is correct
9 Correct 1 ms 10588 KB Output is correct
10 Correct 2 ms 16728 KB Output is correct
11 Correct 3 ms 18780 KB Output is correct
12 Correct 4 ms 26972 KB Output is correct
13 Correct 4 ms 16732 KB Output is correct
14 Incorrect 0 ms 344 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 2 ms 10588 KB Output is correct
9 Correct 1 ms 10588 KB Output is correct
10 Correct 2 ms 16728 KB Output is correct
11 Correct 3 ms 18780 KB Output is correct
12 Correct 4 ms 26972 KB Output is correct
13 Correct 4 ms 16732 KB Output is correct
14 Incorrect 0 ms 344 KB Output isn't correct
15 Halted 0 ms 0 KB -