結果

問題 No.156 キャンディー・ボックス
ユーザー prog470
提出日時 2016-09-13 16:56:04
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 533 bytes
コンパイル時間 798 ms
コンパイル使用メモリ 73,804 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 15:54:50
合計ジャッジ時間 1,735 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main() {

	int N, M;
	cin >> N >> M;
	vector<int> v(N);

	for (int i = 0; i < N; i++) {
		cin>>v[i];
	}

	sort(v.begin(), v.end());

	int cnt = 0, m = 0;
	bool flag = false;
	while (1) {
		v[m]--;
		if (v[m] == 0) m++, cnt++;
		M--;
		if (M == 0) break;
	}

	cout << cnt << endl;

	return 0;
}
0