結果

問題 No.972 選び方のスコア
ユーザー kotatsugame
提出日時 2020-01-17 22:52:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 322 bytes
コンパイル時間 607 ms
コンパイル使用メモリ 68,992 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2024-06-25 23:21:42
合計ジャッジ時間 4,101 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N,A[2<<17];
long S[2<<17];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	sort(A,A+N);
	for(int i=0;i<N;i++)S[i+1]=S[i]+A[i];
	long ans=0;
	for(int i=1;i<N-1;i++)
	{
		int L=min(i,N-1-i);
		ans=max(ans,S[N]-S[N-L]+S[L]-2L*A[i]*L);
	}
	cout<<ans<<endl;
}
0