結果
| 問題 |
No.156 キャンディー・ボックス
|
| コンテスト | |
| ユーザー |
piyoko_212
|
| 提出日時 | 2015-12-28 22:42:29 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 392 bytes |
| コンパイル時間 | 230 ms |
| コンパイル使用メモリ | 34,512 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 15:46:06 |
| 合計ジャッジ時間 | 1,004 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
コンパイルメッセージ
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:8:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | scanf("%d",c+i);
| ~~~~~^~~~~~~~~~
ソースコード
#include<stdio.h>
#include<algorithm>
using namespace std;
int c[110];
int main(){
int a,b;scanf("%d%d",&a,&b);
for(int i=0;i<a;i++){
scanf("%d",c+i);
}
for(int i=0;i<a;i++){
int at=0;
int t=9999999;
for(int j=0;j<a;j++){
if(c[j]&&t>c[j]){
t=c[j];at=j;
}
}
if(b<t)break;
c[at]=0;
b-=t;
}
int ret=0;
for(int i=0;i<a;i++)if(c[i]==0)ret++;
printf("%d\n",ret);
}
piyoko_212