結果

問題 No.972 選び方のスコア
ユーザー FF256grhyFF256grhy
提出日時 2020-01-17 22:31:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,946 bytes
コンパイル時間 1,603 ms
コンパイル使用メモリ 170,476 KB
実行使用メモリ 4,860 KB
最終ジャッジ日時 2023-09-08 04:47:51
合計ジャッジ時間 5,322 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
4,576 KB
testcase_01 AC 90 ms
4,616 KB
testcase_02 AC 87 ms
4,528 KB
testcase_03 AC 43 ms
4,384 KB
testcase_04 AC 84 ms
4,520 KB
testcase_05 AC 83 ms
4,720 KB
testcase_06 AC 83 ms
4,676 KB
testcase_07 AC 69 ms
4,380 KB
testcase_08 AC 75 ms
4,528 KB
testcase_09 AC 72 ms
4,660 KB
testcase_10 AC 73 ms
4,592 KB
testcase_11 AC 79 ms
4,640 KB
testcase_12 AC 77 ms
4,860 KB
testcase_13 AC 76 ms
4,720 KB
testcase_14 AC 75 ms
4,600 KB
testcase_15 AC 78 ms
4,596 KB
testcase_16 AC 80 ms
4,576 KB
testcase_17 AC 79 ms
4,848 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1 ms
4,384 KB
testcase_26 AC 1 ms
4,384 KB
testcase_27 AC 2 ms
4,384 KB
testcase_28 AC 2 ms
4,384 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,384 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,384 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	int n;
	cin >> n;
	vector<LL> a(n);
	inc(i, n) { cin >> a[i]; }
	
	sort(ALL(a));
	
	LL ans = 0, sum = 0;
	inc(i, ce(n, 2)) {
		setmax(ans, sum - 2 * i * a[i]);
		sum += a[i] + a[n - 1 - i];
	}
	
	cout << ans << endl;
	
	return 0;
}
0