이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int n; cin >> n;
ll m; cin >> m;
vector<ll> a(n+1);
for (int i = 1; i <= n; ++i) cin >> a[i];
vector<ll> dp(n+1, -1e7);
dp[0] = 0;
int fixed = 0;
int last = 0;
for (int i = 1; i <= n; ++i) {
if (a[i] <= last + m) {
// this one can stay like that as well
fixed++;
last = a[i];
} else {
last += m;
}
// cerr << "i : " << i << " fixed : " << fixed << endl;
}
// for (auto x : dp) cerr << x << " ";
// cerr << endl;
// int i = 0;
// for (; i <= n; ++i) {
// if (dp[i] < 0) break;
// }
// i--;
// cout << (n - i) << endl;
cout << n - fixed << endl;
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... |