結果
| 問題 | No.609 Noelちゃんと星々 |
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2017-12-09 00:36:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 15 ms / 2,000 ms |
| コード長 | 544 bytes |
| 記録 | |
| コンパイル時間 | 784 ms |
| コンパイル使用メモリ | 79,472 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-29 20:46:31 |
| 合計ジャッジ時間 | 1,957 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> y(n);
for (int i = 0; i < n; i++) {
cin >> y[i];
}
int m = n / 2;
nth_element(y.begin(), y.begin() + m, y.end());
int x = y[m];
int64_t r = 0;
for (int i = 0; i < n; i++) {
r += abs(y[i] - x);
}
cout << r << endl;
return 0;
}
merom686