結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
6,700 KB
testcase_01 AC 94 ms
6,508 KB
testcase_02 AC 89 ms
6,492 KB
testcase_03 AC 43 ms
5,720 KB
testcase_04 AC 85 ms
6,568 KB
testcase_05 AC 85 ms
6,508 KB
testcase_06 AC 87 ms
6,804 KB
testcase_07 AC 71 ms
6,304 KB
testcase_08 AC 79 ms
6,572 KB
testcase_09 AC 74 ms
6,700 KB
testcase_10 AC 74 ms
6,816 KB
testcase_11 AC 80 ms
6,800 KB
testcase_12 AC 80 ms
6,560 KB
testcase_13 AC 80 ms
6,788 KB
testcase_14 AC 80 ms
6,524 KB
testcase_15 AC 80 ms
6,588 KB
testcase_16 AC 82 ms
6,508 KB
testcase_17 AC 82 ms
6,572 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
5,232 KB
testcase_26 AC 3 ms
4,940 KB
testcase_27 AC 2 ms
5,128 KB
testcase_28 AC 2 ms
5,056 KB
testcase_29 AC 2 ms
5,008 KB
testcase_30 AC 3 ms
5,056 KB
testcase_31 AC 2 ms
5,052 KB
testcase_32 AC 3 ms
4,992 KB
testcase_33 AC 3 ms
5,060 KB
testcase_34 AC 2 ms
5,256 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];
*/


ll moP(ll x, ll n) {
  ll res=1;
  while(n>0) {
    if(n&1) moC(res, *, x);
    moC(x, *, x);
    n>>=1;
  }
  return res;
}

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(ll m=1; m<=N/2; m++) {
    ll t=(s[N]-s[N-(m-1)])+s[m-1]-a[m]*(m-1)*2;
    chmax(ans, t);
  }
  
  for(ll m=1; m<=N/2; m++) {
    ll t=(s[N]-s[N-(m-1)])+s[m-1]-(a[m]+a[m+1])*(m-1);
    chmax(ans, t);
  }
  
  
  pt(ans);
  
}

0