結果
問題 | No.609 Noelちゃんと星々 |
ユーザー |
![]() |
提出日時 | 2018-01-30 10:22:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 58 ms / 2,000 ms |
コード長 | 364 bytes |
コンパイル時間 | 767 ms |
コンパイル使用メモリ | 72,524 KB |
最終ジャッジ日時 | 2025-01-05 08:04:14 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include <iostream>#include <algorithm>#define int long longusing namespace std;int n;int y[100000];signed main() {int i;cin >> n;for (i = 0; i < n; i++) cin >> y[i];sort(y, y + n);int a = y[n / 2];int ans = 0;for (i = 0; i < n; i++) {if (y[i] < a) ans += a - y[i];if (y[i] > a) ans += y[i] - a;}cout << ans << endl;return 0;}