結果
問題 | No.5 数字のブロック |
ユーザー |
![]() |
提出日時 | 2015-12-29 00:31:22 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 269 bytes |
コンパイル時間 | 249 ms |
コンパイル使用メモリ | 37,072 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 08:01:11 |
合計ジャッジ時間 | 1,164 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:6:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | int a,b;scanf("%d%d",&a,&b); | ~~~~~^~~~~~~~~~~~~~ main.cpp:7:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | for(int i=0;i<b;i++)scanf("%d",c+i); | ~~~~~^~~~~~~~~~
ソースコード
#include<stdio.h>#include<algorithm>using namespace std;int c[11000];int main(){int a,b;scanf("%d%d",&a,&b);for(int i=0;i<b;i++)scanf("%d",c+i);std::sort(c,c+b);int ret=0;for(int i=0;i<b;i++){if(a>=c[i]){a-=c[i];ret++;}}printf("%d\n",ret);}