結果

問題 No.5 数字のブロック
ユーザー fumi6328fumi6328
提出日時 2018-07-13 20:47:12
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 207 ms / 5,000 ms
コード長 614 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 28,752 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-11 18:27:42
合計ジャッジ時間 2,999 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 81 ms
4,380 KB
testcase_04 AC 21 ms
4,380 KB
testcase_05 AC 129 ms
4,380 KB
testcase_06 AC 55 ms
4,376 KB
testcase_07 AC 37 ms
4,380 KB
testcase_08 AC 67 ms
4,376 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 136 ms
4,380 KB
testcase_11 AC 34 ms
4,508 KB
testcase_12 AC 87 ms
4,380 KB
testcase_13 AC 117 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 136 ms
4,376 KB
testcase_17 AC 188 ms
4,380 KB
testcase_18 AC 156 ms
4,376 KB
testcase_19 AC 207 ms
4,376 KB
testcase_20 AC 0 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 0 ms
4,384 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 20 ms
4,380 KB
testcase_30 AC 12 ms
4,380 KB
testcase_31 AC 0 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>

//vg^Cv錾
void sort(int,int[]);

int main(){
	
//ϐ
	int L,sub,N,W[10000];
	int i;
	int sum=0;
	
//
	scanf("%d%d",&L,&N);
	for(i=0;i<N;i++){
		scanf("%d",&W[i]);
		sum+=W[i];
	}
	sub=L;
//\[g
	sort(N,W);
	
//f
	for(i=0;L>0;i++)
		L-=W[i];
//o
	if(sub>sum)
		printf("%d\n",N);
	else if(L==0)
		printf("%d\n",i);
	else
		printf("%d\n",i-1);
	
	return 0;
}

//\[g֐
void sort(int n,int l[]){
	int i,j,tmp;
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(l[i]>l[j]){
				tmp=l[i];
				l[i]=l[j];
				l[j]=tmp;
			}
		}
	}
}
0