結果
| 問題 |
No.156 キャンディー・ボックス
|
| コンテスト | |
| ユーザー |
latte0119
|
| 提出日時 | 2015-02-26 23:44:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 303 bytes |
| コンパイル時間 | 237 ms |
| コンパイル使用メモリ | 40,576 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-05 08:39:28 |
| 合計ジャッジ時間 | 1,035 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%d%d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:8:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | for(int i=0;i<n;i++)scanf("%d",&val[i]);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int n,m,val[10];
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)scanf("%d",&val[i]);
sort(val,val+n);
int cnt=0;
for(int i=0;i<n;i++){
m-=val[i];
if(m>=0)cnt++;
else break;
}
printf("%d\n",cnt);
return 0;
}
latte0119