提交时间:2023-09-11 14:41:03
运行 ID: 101954
#include <iostream> #include <algorithm> using namespace std; typedef long long LL; int main() { LL n, x, ans = 0, last = 0; cin >> n; for (int i = 1; i <= n; i++) { cin >> x; if (x > last) ans += x - last; last = x; } cout << ans << endl; return 0; }