結果

問題 No.972 選び方のスコア
ユーザー eQeeQe
提出日時 2020-04-02 03:17:28
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 891 bytes
コンパイル時間 1,619 ms
コンパイル使用メモリ 146,768 KB
実行使用メモリ 6,752 KB
最終ジャッジ日時 2023-09-09 22:50:57
合計ジャッジ時間 5,717 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 92 ms
6,732 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 83 ms
6,468 KB
testcase_09 AC 80 ms
6,484 KB
testcase_10 AC 81 ms
6,652 KB
testcase_11 AC 85 ms
6,720 KB
testcase_12 AC 87 ms
6,476 KB
testcase_13 AC 87 ms
6,608 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
5,600 KB
testcase_19 AC 89 ms
6,636 KB
testcase_20 AC 90 ms
6,604 KB
testcase_21 AC 89 ms
6,416 KB
testcase_22 WA -
testcase_23 AC 91 ms
6,460 KB
testcase_24 AC 89 ms
6,520 KB
testcase_25 WA -
testcase_26 AC 2 ms
4,900 KB
testcase_27 WA -
testcase_28 AC 2 ms
5,148 KB
testcase_29 AC 3 ms
5,188 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
5,548 KB
testcase_34 AC 3 ms
6,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main(void) {
  ll i, j, k;
  
  ll N;
  cin >> N;
  ll a[MAX*2];
  ll s[MAX*2]={};
  
  for(i=1; i<=N; i++) cin >> a[i];
  sort(a+1, a+N+1);
  for(i=1; i<=N; i++) s[i]=s[i-1]+a[i];
  
  ll ans=0;
  for(i=1; i<=N; i++) {
    
    ll l=0, r=min(i-1, N-i)+1;
    while(l+1<r) {
      ll m=(l+r)/2;
      ll t=a[N-m]+a[i-1-m]-a[i]*2;
      (t>0 ? l:r)=m;
    }
    
    //pt(i<<" "<<r);
    chmax(ans, (s[N]-s[N-r])+(s[i-1]-s[i-1-r])-a[i]*2*r);
  }
  
  pt(ans);
  
}

0