結果
問題 | No.609 Noelちゃんと星々 |
ユーザー |
![]() |
提出日時 | 2019-06-22 23:02:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 630 bytes |
コンパイル時間 | 2,061 ms |
コンパイル使用メモリ | 168,520 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-26 10:18:21 |
合計ジャッジ時間 | 3,761 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
// ※※※ 解答不能 ※※※. // -> 知識問題として, 解法を暗記. #include <bits/stdc++.h> using namespace std; using LL = long long; int main() { // 1. 入力情報取得. LL N; scanf("%llu", &N); LL Y[N]; for(int i = 0; i < N; i++) scanf("%llu", &Y[i]); // 2. 昇順sort. sort(Y, Y + N); // 3. Noelちゃんが動かす必要のある距離の総和の最小値 を 計算する. LL m = Y[N / 2]; // 4. 集計. LL ans = 0; for(int i = 0; i < N; i++) ans += abs(Y[i] - m); // 5. 出力. printf("%llu\n", ans); return 0; }