結果

問題 No.156 キャンディー・ボックス
ユーザー ciel
提出日時 2015-02-27 00:49:20
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 244 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 42,752 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 08:40:37
合計ジャッジ時間 1,544 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |         scanf("%d%d",&N,&M);
      |         ~~~~~^~~~~~~~~~~~~~
main.cpp:7:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         for(;N--;)scanf("%d",&x),q.push(-x);
      |                   ~~~~~^~~~~~~~~

ソースコード

diff #

#include <queue>
#include <cstdio>
int main(){
	int N,M,x,r=0;
	scanf("%d%d",&N,&M);
	std::priority_queue<int>q;
	for(;N--;)scanf("%d",&x),q.push(-x);
	for(;M--;){
		x=q.top();
		q.pop();
		if(~x)q.push(x+1);
		else r++;
	}
	printf("%d\n",r);
}
0