結果
| 問題 |
No.156 キャンディー・ボックス
|
| コンテスト | |
| ユーザー |
TLwiegehtt
|
| 提出日時 | 2015-07-07 21:30:56 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 498 bytes |
| コンパイル時間 | 125 ms |
| コンパイル使用メモリ | 21,760 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 09:17:07 |
| 合計ジャッジ時間 | 1,019 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:19:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | scanf("%d %d", &n, &m);
| ^~~~~~~~~~~~~~~~~~~~~~
main.c:21:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | scanf("%d", &c[i]);
| ^~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <stdlib.h>
int compare_int( const void*a, const void*b){
int ta = *(int*)a;
int tb = *(int*)b;
if(ta < tb){
return -1;
}else if(ta > tb){
return 1;
}
return 0;
}
int main(void){
int i,m,n;
int blank = 0;
int c[13];
scanf("%d %d", &n, &m);
for(i=0;i<n;i++){
scanf("%d", &c[i]);
}
qsort(c, n, sizeof(int), compare_int);
for(i=0;i<n;i++){
if(m >= c[i]){
m -= c[i];
blank++;
}else{
break;
}
}
printf("%d\n", blank);
return 0;
}
TLwiegehtt