이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, m;
bool arr[109];
int memo[109][109];
int solve(int day, int cup) {
    if (day >= n) return 0;
    int &ret = memo[day][cup];
    if (ret != -1) return ret;
    ret = 1e9 + 9;
    if (arr[day] == 1) {
        ret = min(ret, solve(day + 1, cup));
    }
    ret = min(ret, solve(day + 1, cup) + 10000);
    ret = min(ret, solve(day + 3, cup + 1) + 25000);
    ret = min(ret, solve(day + 5, cup + 2) + 37000);
    if (cup >= 3) {
        ret = min(ret, solve(day + 1, cup - 3));
    }
    return ret;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int num; cin >> num;
        arr[--num] = true;
    }
    fill(&memo[0][0], &memo[108][109], -1);
    cout << solve(0, 0) << '\n';
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |