From 0e02957a889a1246f701b12c975fa2fd36d2d068 Mon Sep 17 00:00:00 2001 From: hanyixuanten <105723997+hanyixuanten@users.noreply.github.com> Date: Sat, 15 Aug 2026 16:56:46 +0800 Subject: [PATCH] new file: P4552.cpp --- P4552.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 P4552.cpp diff --git a/P4552.cpp b/P4552.cpp new file mode 100644 index 0000000..107aacd --- /dev/null +++ b/P4552.cpp @@ -0,0 +1,29 @@ +// 100 +#include +#include +using namespace std; +int n; +int main() +{ + scanf("%d", &n); + long long x = 0, y = 0; + long long a, pre = 0; + for (int i = 1; i <= n; ++i) + { + scanf("%lld", &a); + if (i == 1) + pre = a; + long long cha = a - pre; + if (cha > 0) + x += cha; + else + y -= cha; + pre = a; + } + printf("%lld\n%lld\n", max(x, y), abs(x - y) + 1); + return 0; +} +/* +1 1 2 2 +1 0 1 0 +*/ \ No newline at end of file