結果

問題 No.972 選び方のスコア
ユーザー utouto97utouto97
提出日時 2020-01-18 13:54:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 664 bytes
コンパイル時間 1,333 ms
コンパイル使用メモリ 149,184 KB
実行使用メモリ 4,884 KB
最終ジャッジ日時 2023-09-09 21:30:14
合計ジャッジ時間 5,722 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
4,640 KB
testcase_01 AC 93 ms
4,536 KB
testcase_02 AC 89 ms
4,576 KB
testcase_03 AC 43 ms
4,380 KB
testcase_04 AC 85 ms
4,652 KB
testcase_05 AC 85 ms
4,584 KB
testcase_06 AC 85 ms
4,680 KB
testcase_07 AC 70 ms
4,380 KB
testcase_08 AC 74 ms
4,580 KB
testcase_09 AC 72 ms
4,628 KB
testcase_10 AC 75 ms
4,632 KB
testcase_11 AC 80 ms
4,544 KB
testcase_12 AC 81 ms
4,756 KB
testcase_13 AC 80 ms
4,696 KB
testcase_14 AC 81 ms
4,708 KB
testcase_15 AC 80 ms
4,744 KB
testcase_16 AC 82 ms
4,712 KB
testcase_17 AC 82 ms
4,676 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 2 ms
4,380 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*
 */

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;


signed main() {
  int n;
  cin >> n;

  vi a(n);
  rep(i, 0, n) cin >> a[i];

  sort(all(a));
  int ans = 0, sum = 0;
  rep(i, 0, n/2+n%2){
    sum += a[i] + a[n-1-i];
    chmax(ans, sum-2*(i+1)*a[i+1]);
  }

  cout << ans << endl;

  return 0;
}

0