結果

問題 No.156 キャンディー・ボックス
ユーザー natoriusan
提出日時 2023-08-06 17:47:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 1,688 ms
コンパイル使用メモリ 194,732 KB
最終ジャッジ日時 2025-02-15 23:46:24
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    
    vector<int> c(n);
    for (auto &i: c) {
        cin >> i;
    }
    
    int ans = 0;
    for (int i = 0; i < m; ++i) {
        int &minValue = *min_element(c.begin(), c.end());
        minValue -= 1;
        if (minValue == 0) {
            ans += 1;
            minValue = numeric_limits<int>::max();
        }
        
    }
    
    cout << ans << endl;
}
0