0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-10 02:18:48 +00:00

P5019 [NOIP2018 提高组] 铺设道路

R52369318
This commit is contained in:
Baoshuo Ren 2021-07-04 11:14:24 +08:00 committed by Baoshuo Ren
parent 1d309f4839
commit bc7231084a
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

View File

@ -0,0 +1,17 @@
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, a[1000005], s;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
s = a[0];
for (int i = 1; i < n; i++) {
s += max(0ll, a[i] - a[i - 1]);
}
cout << s << endl;
return 0;
}