結果
問題 | No.156 キャンディー・ボックス |
ユーザー |
![]() |
提出日時 | 2015-02-26 23:25:39 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 407 bytes |
コンパイル時間 | 383 ms |
コンパイル使用メモリ | 53,504 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 08:38:30 |
合計ジャッジ時間 | 1,235 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | int n,m;scanf("%d%d",&n,&m); | ~~~~~^~~~~~~~~~~~~~ main.cpp:17:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | for(int i=0;i<n;i++)scanf("%d",&c[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <map>#include <vector>#include <algorithm>using namespace std;//namaega184int main(){int n,m;scanf("%d%d",&n,&m);int c[101]={};for(int i=0;i<n;i++)scanf("%d",&c[i]);sort(c,c+n);int s=0,ans=0;for(int i=0;i<n;i++){s+=c[i];if(m>=s)ans++;else break;}printf("%d\n",ans);return 0;}