solved hackerrank's the hurdle race

Signed-off-by: ayham <altffour@protonmail.com>
This commit is contained in:
ayham 2021-05-09 12:24:11 +03:00
parent 752323464f
commit 368e5d2f78
No known key found for this signature in database
GPG Key ID: 81D38F7122AFCC94
1 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,19 @@
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, doses = 0;
vector<int> height;
cin >> n >> k;
for (int i = 0; i < n; i++) {
int tmp;
cin >> tmp;
height.push_back(tmp);
if (k < tmp) {
doses += tmp-k;
k += tmp-k;
}
}
cout << doses << endl;
return 0;
}