This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
#define int i64
#define vi vector<int>
#define vvi vector<vi>
#define vb vector<bool>
#define pii pair<int, int>
#define fi first
#define se second
#define sz(x) (int)(x).size()
signed main(){
ios_base::sync_with_stdio(false); cin.tie(0);
int n, m, ans = 0, last = 0;
cin >> n >> m;
vi h(n);
for(int &i : h)
cin >> i;
if(h[0] > m){
h[0] = m;
ans++;
for(int i = 0; i < n - 1; i++){
if(h[i + 1] - h[i] > m){
ans++;
h[i + 1] = h[i] + m;
}
}
}
for(int i = last; i < n - 1; i++){
if(h[i + 1] - h[i] > m){
ans++;
}
}
cout << ans;
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... |