結果

問題 No.5 数字のブロック
ユーザー fumi6328fumi6328
提出日時 2018-07-08 01:12:00
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 472 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 28,336 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-19 09:40:23
合計ジャッジ時間 3,573 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 76 ms
4,380 KB
testcase_04 AC 14 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 51 ms
4,380 KB
testcase_07 AC 35 ms
4,376 KB
testcase_08 AC 62 ms
4,376 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 121 ms
4,376 KB
testcase_11 AC 31 ms
4,380 KB
testcase_12 AC 82 ms
4,376 KB
testcase_13 AC 107 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 WA -
testcase_16 AC 126 ms
4,380 KB
testcase_17 AC 177 ms
4,380 KB
testcase_18 AC 141 ms
4,376 KB
testcase_19 AC 197 ms
4,380 KB
testcase_20 WA -
testcase_21 AC 0 ms
4,380 KB
testcase_22 AC 0 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>

void sort(int,int*);

int main()
{
	int L,N,W[10000];
	int i;
	
	scanf("%d%d",&L,&N);
	for(i=0;i<N;i++)
		scanf("%d",&W[i]);
		
	sort(N,W);
	
	for(i=0;L>0;i++)
		L-=W[i];
	
	if(W[i]+L==0){
		printf("%d",i);
	}else{
		printf("%d",i-1);
	}
	return 0;
}

void sort(int n,int *w){
	int i,j,tmp;
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(w[i]>w[j]){
				tmp=w[i];
				w[i]=w[j];
				w[j]=tmp;
			}
		}
	}
	return;
}
0