結果

問題 No.972 選び方のスコア
ユーザー butsurizukibutsurizuki
提出日時 2020-05-29 02:51:42
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 995 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 31,872 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-04-21 20:03:54
合計ジャッジ時間 3,506 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
8,832 KB
testcase_01 AC 62 ms
8,960 KB
testcase_02 AC 60 ms
8,704 KB
testcase_03 AC 32 ms
7,296 KB
testcase_04 AC 61 ms
9,088 KB
testcase_05 AC 62 ms
8,832 KB
testcase_06 AC 61 ms
8,832 KB
testcase_07 AC 47 ms
8,192 KB
testcase_08 AC 40 ms
8,064 KB
testcase_09 AC 39 ms
8,064 KB
testcase_10 AC 40 ms
8,192 KB
testcase_11 AC 40 ms
8,064 KB
testcase_12 WA -
testcase_13 AC 45 ms
8,960 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 5 ms
5,888 KB
testcase_26 AC 5 ms
5,888 KB
testcase_27 AC 5 ms
5,888 KB
testcase_28 AC 5 ms
5,760 KB
testcase_29 AC 5 ms
5,760 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 5 ms
5,760 KB
testcase_33 AC 5 ms
5,888 KB
testcase_34 AC 5 ms
5,888 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;i++){
    r=llmax(rw[i]+rw[n]-rw[n-i]-i*(a[i]+a[n-i+1]),r);
  }
  printf("%lld\n",r);
  return 0;
}
0