이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,lzcnt,mmx,abm,avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
const int N = 5e3+3, inf = INT_MAX;
int n, m, mx, a[N], dp[N][N];
// dp[i][j] = altura maxima que puedes conseguir en la plataforma i con j movimientos
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> m;
a[0] = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
dp[0][0] = 0;
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= i; j++) {
int x = -inf;
if (dp[i-1][j] + m >= a[i]) x = max(x, a[i]);
if (j && dp[i-1][j-1] != -inf) x = max(x, dp[i-1][j-1] + m);
dp[i][j] = x;
}
}
int ans = inf;
for (int i = 0; i <= n; i++) {
if (dp[n][i] != -inf) {
ans = i;
break;
}
}
cout << ans << "\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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |