結果
| 問題 | No.198 キャンディー・ボックス2 |
| コンテスト | |
| ユーザー |
machy
|
| 提出日時 | 2015-06-14 11:18:52 |
| 言語 | C++11(廃止可能性あり) (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 824 bytes |
| 記録 | |
| コンパイル時間 | 563 ms |
| コンパイル使用メモリ | 76,288 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-06 20:05:26 |
| 合計ジャッジ時間 | 1,456 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 13 WA * 13 |
ソースコード
#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;
}
machy