結果
問題 | No.1374 Absolute Game |
ユーザー |
|
提出日時 | 2021-02-06 04:41:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,234 bytes |
コンパイル時間 | 1,160 ms |
コンパイル使用メモリ | 95,956 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-02 14:47:57 |
合計ジャッジ時間 | 2,298 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 23 WA * 3 |
ソースコード
#include <iostream>#include <string>#include <algorithm>#include <vector>#include <iomanip>#include <cmath>#include <stdio.h>#include <queue>#include <deque>#include <cstdio>#include <set>#include <map>#include <bitset>#include <stack>#include <cctype>using namespace std;long long c[100010];int main() {int n;cin >> n;for (int i = 0; i < n; i++) {cin >> c[i];}sort(c, c + n);long long ans = -10000000000000007;long long a = 0, b = 0;for (int i = 0; i < n; i++) {if (i % 2 == 0) {a += c[i];}else {b += c[i];}}if (ans < abs(a) - abs(b)) {ans = abs(a) - abs(b);}a = 0, b = 0;for (int i = 0; i < n; i++) {if (i != n - i - 1) {a += c[i];b += c[n - i - 1];}else {a += c[i];}}if (ans < abs(a) - abs(b)) {ans = abs(a) - abs(b);}a = 0, b = 0;for (int i = 0; i < n; i++) {if (i != n - i - 1) {b += c[i];a += c[n - i - 1];}else {b += c[i];}}if (ans < abs(a) - abs(b)) {ans = abs(a) - abs(b);}a = 0, b = 0;for (int i = n - 1; i >= 0; i--) {if (i % 2 == (n - 1) % 2) {a += c[i];}else {b += c[i];}}if (ans < abs(a) - abs(b)) {ans = abs(a) - abs(b);}cout << ans << endl;}