結果
問題 | No.198 キャンディー・ボックス2 |
ユーザー |
![]() |
提出日時 | 2015-05-04 22:36:58 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 686 bytes |
コンパイル時間 | 429 ms |
コンパイル使用メモリ | 64,512 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 19:02:01 |
合計ジャッジ時間 | 1,209 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 10 WA * 16 |
ソースコード
#include <iostream>#include <vector>#include <cmath>#define REP(i, n) for(int i=0;i<(n);i++)using namespace std;int main() {cin.tie(0);ios::sync_with_stdio(false);long B, N;cin >> B >> N;vector<long> C;unsigned long sum = 0;REP(i,N) {long c;cin >> c;sum += c;C.push_back(c);}long ave = static_cast<long>(ceil((double)sum / N));long less = 0, more = 0;for(auto c: C) {if (c > ave) more += c - ave;else if (c < ave) less += ave - c;}if (less == more) {cout << less * 2 << endl;} else {cout << less + more << endl;}return 0;}