結果
| 問題 | No.615 集合に分けよう |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-01-18 06:04:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 595 bytes |
| 記録 | |
| コンパイル時間 | 1,819 ms |
| コンパイル使用メモリ | 170,316 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 16:17:19 |
| 合計ジャッジ時間 | 2,884 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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", ans);
}