답안 #844866

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844866 2023-09-06T06:13:43 Z vjudge1 Holding (COCI20_holding) C++17
110 / 110
55 ms 108600 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
//#define int long long
 
const int MAXN = 100 + 5;
const int MAXK = 10000 + 5;
const int INF = 1e9;

#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    #define OPEN freopen(".in", "r", stdin); \
                 freopen(".out", "w", stdout);
#else
    #define OPEN void(23);
#endif

int dp[MAXN][MAXN][MAXK / 4];

void solve()
{
    memset(dp, -1, sizeof(dp));
    int n, l, r, k; cin >> n >> l >> r >> k;
    vector <int> vec(n +1);
    for(int i = 1; i <= n; i++) cin >> vec[i];

    k = min(k, MAXK / 4);

    function <int(int, int, int)> f = [&](int x, int ind, int nw) -> int
    {
        if(ind > r +1) return INF;
        if(nw > k) return INF;
        if(x == n +1) return (ind == r +1 ? 0 : INF);
        int &it = dp[x][ind][nw];
        if(it != -1) return it;

        //cerr << x << " " << ind << " " << nw << "\n";
        int res = f(x +1, ind +1, nw + abs(ind - x)) + vec[x];
        res = min(res, f(x +1, ind, nw));

        return it = res;
    };

    cout << f(1, l, 0);

    return;
}

int32_t main()
{
    OPEN;

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int t = 1; //cin >> t;
    while(t--)
    {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 108120 KB Output is correct
2 Correct 12 ms 108120 KB Output is correct
3 Correct 13 ms 108120 KB Output is correct
4 Correct 12 ms 108120 KB Output is correct
5 Correct 13 ms 108120 KB Output is correct
6 Correct 12 ms 108124 KB Output is correct
7 Correct 12 ms 108120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 108120 KB Output is correct
2 Correct 12 ms 108120 KB Output is correct
3 Correct 13 ms 108120 KB Output is correct
4 Correct 12 ms 108120 KB Output is correct
5 Correct 13 ms 108120 KB Output is correct
6 Correct 12 ms 108124 KB Output is correct
7 Correct 12 ms 108120 KB Output is correct
8 Correct 12 ms 108120 KB Output is correct
9 Correct 13 ms 108120 KB Output is correct
10 Correct 13 ms 108120 KB Output is correct
11 Correct 14 ms 108124 KB Output is correct
12 Correct 14 ms 108600 KB Output is correct
13 Correct 15 ms 108120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 108120 KB Output is correct
2 Correct 12 ms 108120 KB Output is correct
3 Correct 13 ms 108120 KB Output is correct
4 Correct 12 ms 108120 KB Output is correct
5 Correct 13 ms 108120 KB Output is correct
6 Correct 12 ms 108124 KB Output is correct
7 Correct 12 ms 108120 KB Output is correct
8 Correct 12 ms 108120 KB Output is correct
9 Correct 13 ms 108120 KB Output is correct
10 Correct 13 ms 108120 KB Output is correct
11 Correct 14 ms 108124 KB Output is correct
12 Correct 14 ms 108600 KB Output is correct
13 Correct 15 ms 108120 KB Output is correct
14 Correct 14 ms 108376 KB Output is correct
15 Correct 12 ms 108320 KB Output is correct
16 Correct 12 ms 108376 KB Output is correct
17 Correct 13 ms 108380 KB Output is correct
18 Correct 13 ms 108120 KB Output is correct
19 Correct 14 ms 108120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 108120 KB Output is correct
2 Correct 12 ms 108120 KB Output is correct
3 Correct 13 ms 108120 KB Output is correct
4 Correct 12 ms 108120 KB Output is correct
5 Correct 13 ms 108120 KB Output is correct
6 Correct 12 ms 108124 KB Output is correct
7 Correct 12 ms 108120 KB Output is correct
8 Correct 12 ms 108120 KB Output is correct
9 Correct 13 ms 108120 KB Output is correct
10 Correct 13 ms 108120 KB Output is correct
11 Correct 14 ms 108124 KB Output is correct
12 Correct 14 ms 108600 KB Output is correct
13 Correct 15 ms 108120 KB Output is correct
14 Correct 14 ms 108376 KB Output is correct
15 Correct 12 ms 108320 KB Output is correct
16 Correct 12 ms 108376 KB Output is correct
17 Correct 13 ms 108380 KB Output is correct
18 Correct 13 ms 108120 KB Output is correct
19 Correct 14 ms 108120 KB Output is correct
20 Correct 15 ms 108380 KB Output is correct
21 Correct 13 ms 108380 KB Output is correct
22 Correct 13 ms 108376 KB Output is correct
23 Correct 12 ms 108376 KB Output is correct
24 Correct 26 ms 108120 KB Output is correct
25 Correct 55 ms 108120 KB Output is correct