結果
問題 | No.198 キャンディー・ボックス2 |
ユーザー |
![]() |
提出日時 | 2015-07-25 03:41:48 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 387 bytes |
コンパイル時間 | 562 ms |
コンパイル使用メモリ | 64,552 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 09:04:53 |
合計ジャッジ時間 | 1,423 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> using namespace std; typedef long long LL; int main(){ int b, n; cin >> b >> n; vector<int> c(n); LL sum = b; for (int i = 0; i < n; i++){ cin >> c[i]; sum += c[i]; } sort(c.begin(), c.end()); int t = min((int)(sum / n), c[n / 2]); LL ans = 0; for (int ci : c){ ans += abs(ci - t); } cout << ans << endl; return 0; }