이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <functional>
#include <vector>
using namespace std;
#define F first
#define S second
typedef long long ll;
const string noyes[2] = {"NO", "YES"};
const ll INFLL = (1ll << 62);
const int INF = (1 << 30);
const int MAXN = 300'000;
const ll MOD = 1'000'000'007;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n, D, T;
cin >> n >> D >> T;
ll a[n];
for (int i = 0; i < n; i++)
cin >> a[i];
int dp[n][2];
{
int c = 0;
ll last = INF;
for (int i = 0; i < n; i++) {
last = min(last + 1, a[i]);
c += (last <= T);
dp[i][0] = c;
}
}
for (int i = 0; i < D; i++) {
int cur = i & 1;
for (int t = i; t < n; t++)
dp[t][cur ^ 1] = INF;
for (int t = i; t < n; t++) {
int c = 0;
ll last = INF;
for (int e = t + 1; e < n; e++) {
last = min(last + 1, a[e]);
c += (last <= T);
dp[e][cur ^ 1] = min(dp[e][cur ^ 1], dp[t][cur] + c);
}
}
}
cout << dp[n - 1][D & 1] << "\n";
return 0;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |