結果

問題 No.972 選び方のスコア
ユーザー arupakawaiiiarupakawaiii
提出日時 2020-01-24 23:41:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 547 bytes
コンパイル時間 1,510 ms
コンパイル使用メモリ 170,916 KB
実行使用メモリ 4,976 KB
最終ジャッジ日時 2023-10-12 04:26:34
合計ジャッジ時間 5,222 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 73 ms
4,696 KB
testcase_11 AC 79 ms
4,616 KB
testcase_12 WA -
testcase_13 AC 80 ms
4,576 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1 ms
4,352 KB
testcase_26 AC 1 ms
4,352 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
4,352 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 1 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  ll n;
  cin>>n;
  vector<ll> v(n);
  for(ll i=0;i<n;++i){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  
  ll S=v[0]+v[1]+v[n-1];
  ll odd=1;
  ll even=2;
  ll cen=v[1];
  ll max=S-cen*3;
  ll tmp;
  for(ll i=4;i<=n;++i){
    if(i%2==1){
      odd++;
      cen=v[even];
      S+=v[n-odd];
      tmp=cen*i;
    }else{
      even++;
      S+=v[even];
      cen=v[even-1]+v[even];
      tmp=cen*i/2;
    }
    max=max<(S-tmp)?(S-tmp):max;
  }
  cout<<max<<endl;
}
0