結果

問題 No.156 キャンディー・ボックス
ユーザー zaichu
提出日時 2015-12-20 03:15:38
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 392 bytes
コンパイル時間 1,241 ms
コンパイル使用メモリ 163,472 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 15:46:01
合計ジャッジ時間 2,088 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
	long long int n,m;
	cin >> n >> m;
	vector<long long int> data(n);
	for(auto &a:data) cin >> a;
	long long int check = 0;
	sort(data.begin(),data.end());
	while(m > 0){
		if(data[check] == 0) check++;
		data[check] -= 1;
		m--;
	}
	long long int count = 0;
	for(auto a:data) if(a == 0) count++;
	cout << count << endl;
	return 0;
}
0