結果

問題 No.5 数字のブロック
ユーザー fumi6328fumi6328
提出日時 2018-07-13 20:50:29
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 193 ms / 5,000 ms
コード長 620 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 28,444 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-11 18:27:54
合計ジャッジ時間 2,918 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 AC 76 ms
4,380 KB
testcase_04 AC 15 ms
4,380 KB
testcase_05 AC 122 ms
4,380 KB
testcase_06 AC 52 ms
4,376 KB
testcase_07 AC 35 ms
4,380 KB
testcase_08 AC 62 ms
4,380 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 123 ms
4,380 KB
testcase_11 AC 30 ms
4,380 KB
testcase_12 AC 83 ms
4,376 KB
testcase_13 AC 107 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 127 ms
4,376 KB
testcase_17 AC 174 ms
4,376 KB
testcase_18 AC 141 ms
4,376 KB
testcase_19 AC 193 ms
4,380 KB
testcase_20 AC 1 ms
4,388 KB
testcase_21 AC 0 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,380 KB
testcase_27 AC 1 ms
4,384 KB
testcase_28 AC 0 ms
4,380 KB
testcase_29 AC 14 ms
4,380 KB
testcase_30 AC 11 ms
4,380 KB
testcase_31 AC 0 ms
4,380 KB
testcase_32 AC 1 ms
4,380 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