結果
問題 | No.609 Noelちゃんと星々 |
ユーザー |
![]() |
提出日時 | 2019-03-19 01:27:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 485 bytes |
コンパイル時間 | 1,372 ms |
コンパイル使用メモリ | 68,468 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 20:42:36 |
合計ジャッジ時間 | 3,214 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include <iostream>#include <algorithm>#include <string>#include <vector>#include <math.h>using ll = long long;using namespace std;const int MOD = 1e9+7;int main() {int N;cin >> N;vector<int> Y(N);for(int i = 0; i < N; i++){cin >> Y[i];}sort(Y.begin(), Y.end());ll p = (Y[(N-1)/2] + Y[N/2]) / 2;ll ans = 0;for(int i = 0; i < N; i++){ans += abs(Y[i] - p);}cout << ans << endl;return 0;}