From bc7231084a0a04382523162be7aee8ac402fade1 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sun, 4 Jul 2021 11:14:24 +0800 Subject: [PATCH] =?UTF-8?q?P5019=20[NOIP2018=20=E6=8F=90=E9=AB=98=E7=BB=84?= =?UTF-8?q?]=20=E9=93=BA=E8=AE=BE=E9=81=93=E8=B7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R52369318 --- Luogu/problem/P5019/P5019.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Luogu/problem/P5019/P5019.cpp diff --git a/Luogu/problem/P5019/P5019.cpp b/Luogu/problem/P5019/P5019.cpp new file mode 100644 index 00000000..7f5a6ff6 --- /dev/null +++ b/Luogu/problem/P5019/P5019.cpp @@ -0,0 +1,17 @@ +#include + +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; +}