結果
| 問題 | No.615 集合に分けよう | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-01-18 06:04:23 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 597 bytes | 
| コンパイル時間 | 1,492 ms | 
| コンパイル使用メモリ | 171,780 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-07-04 16:17:34 | 
| 合計ジャッジ時間 | 2,582 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 5 | 
| other | AC * 4 WA * 22 | 
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
int scan() {
  auto minus = false;
  auto result = 0;
  while (true) {
    auto k = getchar_unlocked();
    if (k == '-')
      minus = true;
    else if (k < '0' || k > '9')
      break;
    else
      result = 10 * result + k - '0';
  }
  return result * (minus ? -1 : 1);
}
int main() {
  auto n = scan();
  vector<int> Y(n);
  REP(i, n) Y[i] = scan();
  sort(Y.begin(), Y.end());
  auto mid = Y[n / 2];
  auto ans = 0;
  REP(i, n) ans += abs(Y[i] - mid);
  printf("%d\n", ans);
}
            
            
            
        