結果

問題 No.5 数字のブロック
ユーザー fumi6328fumi6328
提出日時 2018-07-08 01:37:52
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 568 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 28,532 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 02:50:43
合計ジャッジ時間 2,780 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<stdio.h>

void sort(int,int*);

int main()
{
	int L,N,W[10000];
	int i;
	int sub,sum=0;
	
	scanf("%d%d",&L,&N);
	for(i=0;i<N;i++){
		scanf("%d",&W[i]);
		sum+=W[i];
	}
	
	sort(N,W);
	
	sub=L;
	for(i=0;L>0;i++)
		L-=W[i];
	
	if(sub>sum){
		printf("%d",N);
	}else{
		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