結果
問題 | No.198 キャンディー・ボックス2 |
ユーザー | machy |
提出日時 | 2015-06-14 11:18:52 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 824 bytes |
コンパイル時間 | 764 ms |
コンパイル使用メモリ | 75,452 KB |
実行使用メモリ | 4,504 KB |
最終ジャッジ日時 | 2023-09-21 01:20:48 |
合計ジャッジ時間 | 1,992 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,376 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 2 ms
4,376 KB |
testcase_11 | AC | 1 ms
4,380 KB |
testcase_12 | AC | 2 ms
4,380 KB |
testcase_13 | WA | - |
testcase_14 | AC | 1 ms
4,380 KB |
testcase_15 | AC | 1 ms
4,380 KB |
testcase_16 | AC | 2 ms
4,380 KB |
testcase_17 | AC | 1 ms
4,380 KB |
testcase_18 | AC | 1 ms
4,376 KB |
testcase_19 | AC | 1 ms
4,376 KB |
testcase_20 | AC | 2 ms
4,380 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 1 ms
4,376 KB |
testcase_25 | WA | - |
testcase_26 | AC | 2 ms
4,376 KB |
testcase_27 | AC | 1 ms
4,380 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
ソースコード
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <cmath> #include <iomanip> #include <map> #include <numeric> using namespace std; typedef long long LL; int main(){ LL B, N; cin >> B >> N; vector<LL> C(N); for(int i = 0; i < N; i++){ cin >> C[i]; } LL ans = accumulate(C.begin(), C.end(), 0); for(int i = 0; i < N; i++){ LL target = C[i]; LL short_cnt = 0; LL over_cnt = 0; for(int j = 0; j < N; j++){ if(C[j] - target < 0){ short_cnt += -(C[j] - target); }else{ over_cnt += C[j] - target; } } if(short_cnt <= over_cnt + B){ ans = min(ans, short_cnt + over_cnt); } } cout << ans << endl; return 0; }