結果

問題 No.972 選び方のスコア
ユーザー HIR180HIR180
提出日時 2020-01-17 21:28:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,010 bytes
コンパイル時間 2,560 ms
コンパイル使用メモリ 188,084 KB
実行使用メモリ 6,812 KB
最終ジャッジ日時 2023-09-08 01:33:21
合計ジャッジ時間 7,392 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
6,512 KB
testcase_01 AC 43 ms
6,584 KB
testcase_02 AC 41 ms
6,408 KB
testcase_03 AC 21 ms
4,944 KB
testcase_04 AC 42 ms
6,516 KB
testcase_05 AC 41 ms
6,528 KB
testcase_06 AC 42 ms
6,512 KB
testcase_07 AC 31 ms
5,744 KB
testcase_08 AC 29 ms
6,528 KB
testcase_09 AC 28 ms
6,692 KB
testcase_10 AC 30 ms
6,588 KB
testcase_11 AC 30 ms
6,524 KB
testcase_12 AC 31 ms
6,516 KB
testcase_13 AC 31 ms
6,584 KB
testcase_14 AC 31 ms
6,688 KB
testcase_15 AC 32 ms
6,512 KB
testcase_16 AC 32 ms
6,640 KB
testcase_17 AC 33 ms
6,528 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,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
ll a[200005],rui[200005];
ll ans = -1e18;
int main(){
	scanf("%d",&n);
	repn(i,n) scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	repn(i,n) rui[i] = rui[i-1]+a[i];
	for(int i=1;i<=n;i+=2){
		int x = (i+1)/2;
		int y = i/2;
		ll sum = rui[x] + rui[n] - rui[n-y];
		ll gen = 1LL*i*a[x];
		ans = max(ans,sum-gen);
	}
	cout<<ans<<endl;
}
0