이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#warning That's not the baby, that's my baby
#define debug(x) #x << " = " << x << '\n'
using ll = long long;
const ll INF = 1e18;
const int mod = 1e9 + 7;
int toHash(std::vector<ll> x) {
int ret = 0;
for (int i = 0; i < (int) x.size(); i++) {
x[i] %= mod;
ret = ((ll) ret * 23 + x[i]) % mod;
}
return ret;
}
int solve(int n, int k, int *A) {
std::vector<ll> dp(n + 1, INF);
std::vector<int> a(n + 1, 0);
for (int i = 0; i < n; i++) {
a[i + 1] = A[i];
}
dp[0] = 0;
for (int i = 1; i <= n; i++) {
int maxi = 0;
for (int j = i; j > 0 && j > i - k; j--) {
maxi = std::max(maxi, a[j]);
dp[i] = std::min(dp[i], dp[j - 1] + maxi);
}
}
dp.erase(dp.begin());
return toHash(dp);
}
#ifdef LOCAL
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
int n, k;
std::cin >> n >> k;
int *a = new int[n];
for (int i = 0; i < n; i++) {
std::cin >> a[i];
}
std::cout << solve(n, k, a);
return 0;
}
#endif
컴파일 시 표준 에러 (stderr) 메시지
peru.cpp:5:2: warning: #warning That's not the baby, that's my baby [-Wcpp]
5 | #warning That's not the baby, that's my baby
| ^~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |