結果

問題 No.972 選び方のスコア
ユーザー 沙耶花沙耶花
提出日時 2020-01-14 13:49:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 781 bytes
コンパイル時間 2,370 ms
コンパイル使用メモリ 204,288 KB
実行使用メモリ 4,916 KB
最終ジャッジ日時 2023-08-26 06:03:43
合計ジャッジ時間 10,204 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 180 ms
4,636 KB
testcase_01 AC 180 ms
4,616 KB
testcase_02 AC 169 ms
4,616 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 241 ms
4,568 KB
testcase_06 WA -
testcase_07 AC 130 ms
4,380 KB
testcase_08 AC 161 ms
4,612 KB
testcase_09 AC 154 ms
4,624 KB
testcase_10 AC 100 ms
4,680 KB
testcase_11 AC 105 ms
4,736 KB
testcase_12 WA -
testcase_13 AC 109 ms
4,568 KB
testcase_14 WA -
testcase_15 AC 114 ms
4,568 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 170 ms
4,644 KB
testcase_20 WA -
testcase_21 AC 167 ms
4,676 KB
testcase_22 AC 230 ms
4,564 KB
testcase_23 AC 168 ms
4,628 KB
testcase_24 AC 168 ms
4,620 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 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 2 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,384 KB
testcase_34 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:37:13: 警告: ‘ind’ may be used uninitialized [-Wmaybe-uninitialized]
   37 |         int ind;
      |             ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000.0

long long get_score(vector<long long> &a,int m){
	if(m>=a.size()||m<0)return 0;
	long long ret = 0;
	
	long long S = 0;
	
	for(int i=m-1;i>=0;i--){
		S += a[i];
		S += a[a.size()-1 - (m-1-i)];
		S -= 2*a[m];
		ret = max(ret,S);
	}
	
	return ret;
}


int main(){
	
	int N;
	cin>>N;
	
	vector<long long> a(N);
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	
	sort(a.begin(),a.end());
	
	long long ans = -1;
	int ind;
	
	for(int i=0;i<N;i+=1000){
		long long s = get_score(a,i);
		if(s>ans){
			ans = s;
			ind = i;
		}
	}
	
	for(int i=ind-500;i<=ind+500;i++){
		ans = max(ans,get_score(a,i));
	}
	
	
	cout<<ans<<endl;
	
	
    return 0;
}
0