結果

問題 No.972 選び方のスコア
ユーザー chocopuuchocopuu
提出日時 2020-01-17 22:45:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,734 bytes
コンパイル時間 2,104 ms
コンパイル使用メモリ 169,792 KB
実行使用メモリ 6,420 KB
最終ジャッジ日時 2023-09-08 05:35:40
合計ジャッジ時間 5,535 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
6,256 KB
testcase_01 AC 93 ms
6,304 KB
testcase_02 AC 87 ms
6,204 KB
testcase_03 AC 42 ms
4,556 KB
testcase_04 AC 84 ms
6,260 KB
testcase_05 AC 83 ms
6,256 KB
testcase_06 AC 84 ms
6,212 KB
testcase_07 AC 68 ms
5,468 KB
testcase_08 AC 76 ms
6,244 KB
testcase_09 AC 72 ms
5,888 KB
testcase_10 AC 74 ms
6,136 KB
testcase_11 AC 78 ms
6,268 KB
testcase_12 AC 78 ms
6,128 KB
testcase_13 AC 78 ms
6,192 KB
testcase_14 AC 77 ms
6,304 KB
testcase_15 AC 78 ms
6,200 KB
testcase_16 AC 79 ms
6,420 KB
testcase_17 AC 81 ms
6,316 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,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
/*
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void in(T&t){cin>>t;}
template<class T,class... Ts>inline void in(T&t,Ts&...ts){cin>>t;in(ts...);}
template<class T>inline void out(T t){cout<<t<<endl;}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill(T&t,const V&v){for(auto &e:t)fill(e,v);}
constexpr long long INF = 1e18;

signed main(){
	int N;
	in(N);
	auto a = mv(N);
	in(a);
	sort(ALL(a));
	auto as = mv(N+1);
	REP(i,N)as[i+1] = as[i] + a[i];
	int ans = 0;
	REP(i,N){
		int ai = min(i,N-i-1);
		int lo = as[ai]-as[0];
		int hi = as[N]-as[N-ai];
		int cost = lo-a[i]*ai;
		cost += hi-a[i]*ai;
		CHMAX(ans,cost);
	}
	out(ans);
}
0