1 条题解
-
0Jong-oo LV 7 @ 2020-04-08 15:04:48
#include <iostream> #include <algorithm> using namespace std; int main() { int n, h, h0 = 0, ans = 0; cin >> n; for (int i = 1; i <= n; i++) { cin >> h; if (h0 > h) ans += h0 - h; h0 = h; } ans += h; cout << ans << endl; return 0; }
- 1