結果

問題 No.972 選び方のスコア
ユーザー CleyLCleyL
提出日時 2020-01-17 21:51:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 464 bytes
コンパイル時間 639 ms
コンパイル使用メモリ 74,228 KB
実行使用メモリ 4,932 KB
最終ジャッジ日時 2023-09-08 02:27:47
合計ジャッジ時間 4,327 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
4,892 KB
testcase_01 AC 90 ms
4,716 KB
testcase_02 AC 88 ms
4,588 KB
testcase_03 AC 42 ms
4,376 KB
testcase_04 AC 82 ms
4,604 KB
testcase_05 AC 81 ms
4,748 KB
testcase_06 AC 82 ms
4,580 KB
testcase_07 AC 70 ms
4,380 KB
testcase_08 AC 73 ms
4,632 KB
testcase_09 AC 69 ms
4,544 KB
testcase_10 AC 71 ms
4,596 KB
testcase_11 AC 77 ms
4,752 KB
testcase_12 AC 79 ms
4,576 KB
testcase_13 AC 79 ms
4,620 KB
testcase_14 AC 80 ms
4,788 KB
testcase_15 AC 80 ms
4,588 KB
testcase_16 AC 81 ms
4,592 KB
testcase_17 AC 82 ms
4,916 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,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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];
  long long ce = a[0];
  for(int i = 1; i < n-i; i++){
    nw += a[i]+a[n-i];
    ce = a[i];
    ans = max(ans,nw-(i*2+1)*ce);
  }
  cout << ans << endl;
}
0