mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
T208078 [Kubic] Addition
R61305013
This commit is contained in:
parent
7536cc5945
commit
56273f8b48
21
Luogu/contest/54519/T208078/T208078.cpp
Normal file
21
Luogu/contest/54519/T208078/T208078.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
long long n, a[100005];
|
||||
|
||||
int main() {
|
||||
cin >> n;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i];
|
||||
}
|
||||
for (int i = n; i > 2; i--) {
|
||||
if (abs(a[i - 1] - a[i]) > abs(a[i - 1] + a[i])) {
|
||||
a[i - 1] -= a[i];
|
||||
} else {
|
||||
a[i - 1] += a[i];
|
||||
}
|
||||
}
|
||||
cout << max(a[1] - a[2], a[1] + a[2]) << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user