結果

問題 No.156 キャンディー・ボックス
ユーザー d_sei
提出日時 2019-08-27 15:02:32
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 788 ms
コンパイル使用メモリ 85,676 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-15 19:18:18
合計ジャッジ時間 2,059 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include <vector>
#include<cmath>
#include<iomanip>
using namespace std;
typedef long long int lont;
int main() {
	int N, M;
	cin >> N >> M;
	vector<int>veca(N);
	for (int ia = 0; ia < N; ia++) {
		cin >> veca.at(ia);
	}
	sort(veca.begin(), veca.end());
	for (int ib = 0; ib < M; ib++) {
		for (int id = 0; id <N; id++) {
			if (veca.at(id) != 0) {
				veca.at(id)--;
				break;
			}
		}
	}
	int cnta = 0;
	for (int ic = 0; ic < N; ic++) {
		if (veca.at(ic) == 0) {
			cnta++;
		}
	}
	cout << cnta << endl;
}
0