結果
問題 |
No.609 Noelちゃんと星々
|
ユーザー |
|
提出日時 | 2020-04-16 09:09:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 489 bytes |
コンパイル時間 | 1,402 ms |
コンパイル使用メモリ | 94,500 KB |
最終ジャッジ日時 | 2025-01-09 19:24:16 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include <iostream> #include <algorithm> #include <cmath> #include <vector> using lint = long long; void solve() { int n; std::cin >> n; std::vector<lint> xs(n); for (auto& x : xs) std::cin >> x; std::sort(xs.begin(), xs.end()); lint g = xs[n / 2]; lint ans = 0; for (auto x : xs) ans += std::abs(x - g); std::cout << ans << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }