Submission #970529

# Submission time Handle Problem Language Result Execution time Memory
970529 2024-04-26T16:31:58 Z RandomUser Holding (COCI20_holding) C++17
55 / 110
77 ms 100404 KB
#include <bits/stdc++.h>

#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
//#define int long long

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
const double eps = 1e-9;

int32_t main() {
    int n, l, r, K;
    cin >> n >> l >> r >> K;

    vector<int> v(n+1);
    for(int i=1; i<=n; i++) cin >> v[i];

    ll sum = 0;
    for(int i=l; i<=r; i++) sum += v[i];

    if(r == n) {
        ll dp[l][n+1][K+1];
        memset(dp, 0, sizeof(dp));

        for(int i=1; i<l; i++) {
            for(int j=l; j<=r; j++) {
                for(int k=0; k<=K; k++) {
                    dp[i][j][k] = min(dp[i][j][k], dp[i-1][j][k]);
                    dp[i][j][k] = min(dp[i][j][k], dp[i][j-1][k]);
                    if(j - i <= k) dp[i][j][k] = min(dp[i][j][k], dp[i-1][j-1][k-j+i] + v[i] - v[j]);
                }
            }
        }

        cout << sum + dp[l-1][n][K] << '\n';
        return 0;
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 4 ms 6324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 4 ms 6324 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 1 ms 1200 KB Output is correct
11 Correct 1 ms 1884 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 77 ms 100404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 4 ms 6324 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 1 ms 1200 KB Output is correct
11 Correct 1 ms 1884 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 77 ms 100404 KB Output is correct
14 Incorrect 1 ms 344 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 4 ms 6324 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 1 ms 1200 KB Output is correct
11 Correct 1 ms 1884 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 77 ms 100404 KB Output is correct
14 Incorrect 1 ms 344 KB Output isn't correct
15 Halted 0 ms 0 KB -