'commit'
This commit is contained in:
26
TangDou/AcWing_TiGao/T6/QianZuiHeChaFen/100.cpp
Normal file
26
TangDou/AcWing_TiGao/T6/QianZuiHeChaFen/100.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef long long LL;
|
||||
const int N = 100010;
|
||||
|
||||
int n;
|
||||
int a[N], b[N];
|
||||
|
||||
int main() {
|
||||
cin >> n;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i];
|
||||
b[i] = a[i] - a[i - 1];
|
||||
}
|
||||
|
||||
LL p = 0, q = 0;
|
||||
for (int i = 2; i <= n; i++)
|
||||
if (b[i] > 0)
|
||||
p += b[i];
|
||||
else
|
||||
q -= b[i];
|
||||
|
||||
printf("%lld\n%lld\n", max(p, q), abs(p - q) + 1);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user