結果

問題 No.198 キャンディー・ボックス2
ユーザー erieri
提出日時 2015-07-25 03:36:19
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 385 bytes
コンパイル時間 577 ms
コンパイル使用メモリ 66,552 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-23 04:30:20
合計ジャッジ時間 1,900 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 WA -
testcase_29 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0