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;
int main(){
int n, m;
cin >> n >> m;
vector<int> heights(n);
for(int i= 0 ;i<n; i++){
cin >> heights[i];
}
vector<int> difs(n);
int count = 0;
difs[0] = heights[0]-m;
for(int i = 1; i<n; i++){
difs[i] = heights[i]-heights[i-1]-m;
}
int spot = 0;
while(difs[spot]>0){
int makeup = difs[spot];
count++;
if(spot+1<n){
difs[spot+1]+=makeup;
}
spot++;
}
while(spot<n){
if(difs[spot]>0){
count++;
}
spot++;
}
cout<<count;
}
# | 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... |