結果

問題 No.972 選び方のスコア
ユーザー butsurizukibutsurizuki
提出日時 2020-05-29 02:55:11
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,053 bytes
コンパイル時間 558 ms
コンパイル使用メモリ 29,916 KB
実行使用メモリ 11,300 KB
最終ジャッジ日時 2023-08-03 21:38:19
合計ジャッジ時間 3,656 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
8,992 KB
testcase_01 AC 58 ms
9,140 KB
testcase_02 AC 56 ms
9,232 KB
testcase_03 AC 29 ms
7,912 KB
testcase_04 AC 58 ms
9,184 KB
testcase_05 AC 57 ms
9,100 KB
testcase_06 AC 58 ms
9,144 KB
testcase_07 AC 45 ms
8,552 KB
testcase_08 AC 35 ms
8,064 KB
testcase_09 AC 34 ms
10,508 KB
testcase_10 AC 36 ms
10,420 KB
testcase_11 AC 36 ms
10,500 KB
testcase_12 AC 37 ms
10,696 KB
testcase_13 AC 41 ms
11,168 KB
testcase_14 AC 36 ms
8,004 KB
testcase_15 AC 44 ms
11,284 KB
testcase_16 AC 44 ms
9,256 KB
testcase_17 AC 44 ms
11,104 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
6,188 KB
testcase_26 AC 2 ms
6,160 KB
testcase_27 AC 2 ms
6,096 KB
testcase_28 AC 3 ms
6,928 KB
testcase_29 AC 2 ms
6,564 KB
testcase_30 AC 2 ms
6,300 KB
testcase_31 AC 3 ms
7,192 KB
testcase_32 AC 2 ms
6,184 KB
testcase_33 AC 2 ms
6,856 KB
testcase_34 AC 2 ms
6,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//set many funcs template
//Ver.20190820
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<assert.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
#define size 524288

long long llmax(long long a,long long b){if(a>b){return a;}return b;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}

int main(void){
  long long i,j,n,m,k,a[size],b,c,h,w,r=0,l,t;
  long long rw[size]={0};
  scanf("%lld",&n);
  for(i=1;i<=n;i++){
    scanf("%lld",&a[i]);
  }
  qsort(&a[1],n,sizeof(long long),llsortfncsj);
  for(i=1;i<=n;i++){
    rw[i]=rw[i-1]+a[i];
  }
  if(n<=2){puts("0");return 0;}
  for(i=1;(2*i+1)<=n;i++){
    r=llmax(rw[i+1]+rw[n]-rw[n-i]-(2*i+1)*a[i+1],r);
  }
  for(i=1;i<=(n/2);i++){
    r=llmax(rw[i]+rw[n]-rw[n-i]-i*(a[i]+a[n-i]),r);
    r=llmax(rw[i+1]+rw[n]-rw[n-i+1]-i*(a[i]+a[i+1]),r);
  }
  printf("%lld\n",r);
  return 0;
}
0