結果
| 問題 |
No.156 キャンディー・ボックス
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-05-06 01:27:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 243 bytes |
| コンパイル時間 | 205 ms |
| コンパイル使用メモリ | 37,072 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 19:10:27 |
| 合計ジャッジ時間 | 1,039 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| other | AC * 18 WA * 12 |
コンパイルメッセージ
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);
| ~~~~~^~~~~~~~~~
ソースコード
#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+1);
}