結果

問題 No.972 選び方のスコア
ユーザー kotatsugamekotatsugame
提出日時 2020-01-17 22:57:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 436 bytes
コンパイル時間 588 ms
コンパイル使用メモリ 70,512 KB
実行使用メモリ 7,236 KB
最終ジャッジ日時 2023-09-08 06:23:31
合計ジャッジ時間 4,697 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
7,020 KB
testcase_01 AC 105 ms
7,012 KB
testcase_02 AC 100 ms
7,040 KB
testcase_03 AC 49 ms
6,300 KB
testcase_04 AC 98 ms
6,972 KB
testcase_05 AC 98 ms
7,008 KB
testcase_06 AC 99 ms
6,960 KB
testcase_07 AC 78 ms
6,576 KB
testcase_08 AC 88 ms
6,932 KB
testcase_09 AC 85 ms
6,952 KB
testcase_10 AC 86 ms
7,236 KB
testcase_11 AC 92 ms
6,960 KB
testcase_12 AC 93 ms
7,004 KB
testcase_13 AC 92 ms
6,968 KB
testcase_14 AC 92 ms
7,072 KB
testcase_15 AC 93 ms
6,928 KB
testcase_16 AC 94 ms
7,012 KB
testcase_17 AC 95 ms
6,952 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
5,372 KB
testcase_26 AC 2 ms
5,440 KB
testcase_27 AC 2 ms
5,460 KB
testcase_28 AC 2 ms
5,384 KB
testcase_29 AC 2 ms
5,364 KB
testcase_30 AC 2 ms
5,648 KB
testcase_31 AC 2 ms
5,372 KB
testcase_32 AC 2 ms
5,444 KB
testcase_33 AC 2 ms
5,556 KB
testcase_34 AC 2 ms
5,636 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N;
long 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 lim=min(i,N-1-i);
		long L=0,R=lim+1;
		while(R-L>1)
		{
			long M=(L+R)/2;
			if(A[N-M]+A[i-M]>A[i]*2)L=M;
			else R=M;
		}
		ans=max(ans,S[N]-S[N-L]+S[L]-2*L*A[i]);
	}
	cout<<ans<<endl;
}
0