답안 #486965

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
486965 2021-11-13T15:06:56 Z Neos Holding (COCI20_holding) C++14
88 / 110
25 ms 16280 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vii> vvii;

#define task "holding"
#define fastIO ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define forw(i, l, r) for( ll i = (l) ; i < (r) ; i++ )
#define forb(i, r, l) for( ll i = (r) ; i >= (l) ; i-- )
#define numBit(x) (__builtin_popcountll(1ll * (x)))
#define getBit(x, i) ((x) >> (i) & 1)
#define sz(x) (int)x.size()
#define mp make_pair
#define fi first
#define se second
#define ar array
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define debug(x) cerr << #x << " = " << x << '\n';

const int N = 101;
const int M = 2502;

int n, l, r, k, a[N];
int dp[N][N][M];

int DP(int pos, int _at, int k) {
    if (_at > r) return (k < 0 ? 1e9 : 0);
    if (pos > n || k < 0) return 1e9;
    if (dp[pos][_at][k]) return dp[pos][_at][k];

    int cost = abs(pos - _at);

    int mn = DP(pos + 1, _at, k);
    if (k >= cost) mn = min(mn, DP(pos + 1, _at + 1, k - cost) + a[pos]);
    return dp[pos][_at][k] = mn;
}

int main() {
//    fastIO;
    cin >> n >> l >> r >> k;
    forw(i, 1, n + 1) cin >> a[i];
    cout << DP(1, l, k);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 1484 KB Output is correct
9 Correct 1 ms 1996 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 3 ms 4172 KB Output is correct
12 Correct 3 ms 4940 KB Output is correct
13 Correct 5 ms 4812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 1484 KB Output is correct
9 Correct 1 ms 1996 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 3 ms 4172 KB Output is correct
12 Correct 3 ms 4940 KB Output is correct
13 Correct 5 ms 4812 KB Output is correct
14 Correct 0 ms 560 KB Output is correct
15 Correct 1 ms 1100 KB Output is correct
16 Correct 1 ms 1612 KB Output is correct
17 Correct 2 ms 1740 KB Output is correct
18 Correct 3 ms 2892 KB Output is correct
19 Correct 5 ms 4908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 1484 KB Output is correct
9 Correct 1 ms 1996 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 3 ms 4172 KB Output is correct
12 Correct 3 ms 4940 KB Output is correct
13 Correct 5 ms 4812 KB Output is correct
14 Correct 0 ms 560 KB Output is correct
15 Correct 1 ms 1100 KB Output is correct
16 Correct 1 ms 1612 KB Output is correct
17 Correct 2 ms 1740 KB Output is correct
18 Correct 3 ms 2892 KB Output is correct
19 Correct 5 ms 4908 KB Output is correct
20 Correct 5 ms 4940 KB Output is correct
21 Correct 3 ms 2124 KB Output is correct
22 Correct 3 ms 4684 KB Output is correct
23 Correct 1 ms 1228 KB Output is correct
24 Correct 19 ms 16280 KB Output is correct
25 Runtime error 25 ms 12876 KB Execution killed with signal 11