結果

問題 No.972 選び方のスコア
ユーザー ransewhaleransewhale
提出日時 2020-01-17 22:16:27
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 643 bytes
コンパイル時間 1,629 ms
コンパイル使用メモリ 167,188 KB
実行使用メモリ 6,616 KB
最終ジャッジ日時 2023-09-08 03:46:20
合計ジャッジ時間 5,480 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
6,436 KB
testcase_01 AC 95 ms
6,468 KB
testcase_02 AC 90 ms
6,312 KB
testcase_03 AC 44 ms
4,896 KB
testcase_04 AC 87 ms
6,468 KB
testcase_05 AC 86 ms
6,444 KB
testcase_06 AC 87 ms
6,532 KB
testcase_07 AC 71 ms
5,660 KB
testcase_08 AC 76 ms
6,512 KB
testcase_09 AC 73 ms
6,444 KB
testcase_10 AC 77 ms
6,468 KB
testcase_11 AC 82 ms
6,464 KB
testcase_12 AC 83 ms
6,500 KB
testcase_13 AC 83 ms
6,472 KB
testcase_14 AC 82 ms
6,444 KB
testcase_15 AC 83 ms
6,552 KB
testcase_16 AC 84 ms
6,528 KB
testcase_17 AC 84 ms
6,460 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 2 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,384 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll s[225816],a[225816];

int main(void){
	int n,i;
	ll tmp,ans=0ll;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	sort(a,a+n);
	for(i=0; i<n; ++i){
		s[i+1] = s[i]+a[i];
	}
	for(i=(n-1)/2; i>0; --i){
		tmp = s[i]+s[n]-s[n-i];
		tmp -= a[i]*i*2;
		ans = max(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}
0