結果

問題 No.156 キャンディー・ボックス
ユーザー koba-e964
提出日時 2015-05-06 01:29:09
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 240 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 36,664 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 09:14:52
合計ジャッジ時間 1,166 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:6: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 | scanf("%d%d",&n,&m);
      | ~~~~~^~~~~~~~~~~~~~
main.cpp:9:27: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 | for(int i =0;i<n;i++)scanf("%d",a+i);
      |                      ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <algorithm>
using namespace std;

int a[11];
int main(){
int n,m;
scanf("%d%d",&n,&m);
for(int i =0;i<n;i++)scanf("%d",a+i);
sort(a,a+n);
int i;
for(i=0;i<n;i++){
m -= a[i];
if(m<0){
break;
}}
printf("%d\n",i);
}
0