結果

問題 No.972 選び方のスコア
ユーザー tko919tko919
提出日時 2020-01-17 22:03:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 884 bytes
コンパイル時間 1,701 ms
コンパイル使用メモリ 169,900 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 02:59:50
合計ジャッジ時間 4,162 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
4,380 KB
testcase_01 AC 43 ms
4,380 KB
testcase_02 AC 41 ms
4,380 KB
testcase_03 AC 21 ms
4,376 KB
testcase_04 AC 41 ms
4,380 KB
testcase_05 AC 41 ms
4,380 KB
testcase_06 AC 41 ms
4,380 KB
testcase_07 AC 32 ms
4,376 KB
testcase_08 AC 28 ms
4,380 KB
testcase_09 AC 26 ms
4,376 KB
testcase_10 AC 29 ms
4,380 KB
testcase_11 AC 28 ms
4,376 KB
testcase_12 AC 29 ms
4,376 KB
testcase_13 AC 28 ms
4,376 KB
testcase_14 AC 29 ms
4,376 KB
testcase_15 AC 31 ms
4,376 KB
testcase_16 AC 30 ms
4,376 KB
testcase_17 AC 31 ms
4,376 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 1 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,384 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
   int n; scanf("%d",&n);
   vector<int> a(n);
   rep(i,0,n)scanf("%d",&a[i]);
   sort(ALL(a));
   ll ls=0,rs=0,res=0,cur=0;
   rep(i,0,n){
      ll val=a[i];
      cur=ls+rs-val*2*i;
      chmax(res,cur);
      ls+=val; rs+=a[n-1-i];
   }
   printf("%lld\n",res);
   return 0;
}
0