結果
| 問題 | 
                            No.156 キャンディー・ボックス
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2017-03-07 13:41:25 | 
| 言語 | C90  (gcc 12.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 477 bytes | 
| コンパイル時間 | 262 ms | 
| コンパイル使用メモリ | 21,632 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-06-23 17:02:02 | 
| 合計ジャッジ時間 | 1,527 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 4 | 
| other | AC * 2 WA * 28 | 
コンパイルメッセージ
main.c: In function ‘main’:
main.c:25:1: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 | scanf("%d %d",&n,&M);
      | ^~~~~~~~~~~~~~~~~~~~
main.c:28:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |         scanf("%d",&N[i]);
      |         ^~~~~~~~~~~~~~~~~
            
            ソースコード
#include<stdio.h>
#include<stdlib.h>
int sortfnc(const void *a,const void *b){
	if(*(int*)a == *(int*)b){
	return 0;
	}
	if(*(int*)a < *(int*)b)
	{return -1;
	}
	return 1;
}
int main(void){
int n,N[10],M,C,i,total=0;
scanf("%d %d",&n,&M);
for(i=0;i<n;i++){
	scanf("%d",&N[i]);
}
	qsort(N, n, sizeof(int), sortfnc);
for(i=0;i<n;i++){
	while(M>0){
		if(N[i]>0){		N[i]--;
					M--;
		}if(N[i]==0){		total++;
					break;
		}
	}
printf("%d",total);
}
return 0;
}