結果
| 問題 |
No.972 選び方のスコア
|
| コンテスト | |
| ユーザー |
🍮かんプリン
|
| 提出日時 | 2020-06-20 16:32:12 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 586 bytes |
| コンパイル時間 | 1,404 ms |
| コンパイル使用メモリ | 163,212 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-03 17:25:18 |
| 合計ジャッジ時間 | 5,321 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 7 |
ソースコード
/**
* @FileName a.cpp
* @Author kanpurin
* @Created 2020.06.20 16:32:07
**/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
int n;cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
ll ans = 0;
ll x = 0;
ll y = 0;
ll m = a[0];
for (int i = 1; i < n-i; i++) {
y += (a[i] - m) * i;
x -= (a[i] - m) * (i - 1);
x += a[n-i] - a[i];
ans = max(ans,x - y);
m = a[i];
}
cout << ans << endl;
return 0;
}
🍮かんプリン