結果
| 問題 |
No.972 選び方のスコア
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2020-01-17 22:59:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 557 bytes |
| コンパイル時間 | 846 ms |
| コンパイル使用メモリ | 74,544 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-25 23:42:38 |
| 合計ジャッジ時間 | 4,096 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 7 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int n;cin>>n;
if(n < 3){
cout << 0 << endl;
return 0;
}
vector<long long> a(n);
for(int i = 0; n > i; i++){
cin>>a[i];
}
long long ans = 0;
sort(a.begin(),a.end());
long long nw = a[0]+a[1];
long long ce;
for(int i = 1; i <= n-i; i++){//3,5
nw += a[n-i];
ce = a[i];
ans = max(ans,nw-ce*(i*2+1));
if(i == n-i)break;
nw += a[i+1];
ce = a[i]+a[i+1];
ans = max(ans,nw-ce*(i+1));
}
cout << ans << endl;
}