結果

問題 No.5 数字のブロック
ユーザー arutairuarutairu
提出日時 2021-08-21 22:20:08
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 258 ms / 5,000 ms
コード長 504 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 30,208 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 13:18:52
合計ジャッジ時間 2,869 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 100 ms
6,940 KB
testcase_04 AC 57 ms
6,944 KB
testcase_05 AC 151 ms
6,944 KB
testcase_06 AC 59 ms
6,940 KB
testcase_07 AC 40 ms
6,944 KB
testcase_08 AC 78 ms
6,940 KB
testcase_09 AC 9 ms
6,944 KB
testcase_10 AC 183 ms
6,944 KB
testcase_11 AC 37 ms
6,944 KB
testcase_12 AC 97 ms
6,944 KB
testcase_13 AC 146 ms
6,944 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 159 ms
6,944 KB
testcase_17 AC 227 ms
6,944 KB
testcase_18 AC 200 ms
6,940 KB
testcase_19 AC 258 ms
6,944 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 1 ms
6,940 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 AC 1 ms
6,940 KB
testcase_28 AC 1 ms
6,944 KB
testcase_29 AC 55 ms
6,944 KB
testcase_30 AC 13 ms
6,944 KB
testcase_31 AC 1 ms
6,940 KB
testcase_32 AC 1 ms
6,940 KB
testcase_33 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>
 int main(void)
{
	int l;
	int n;
	int w[100001];
	int i;
	int j;
	int temp;
	int sum=0;
	int c=0;
	scanf("%d",&l);
	scanf("%d",&n);
	for(i=0;i<n;i++){
		
		scanf("%d",&w[i]);
		
	}
	for(i=n-1;i>=0;i--){
		for(j=0;j<i;j++){
			if(w[j]>w[j+1]){
				temp=w[j];
				w[j]=w[j+1];
				w[j+1]=temp;
			}
		}
	}
	for(i=0;i<n;i++){
		//printf("%d\n",w[i]);
		sum+=w[i];
		if(sum>=l){
			if(sum==l){
				c++;
			}
			break;
		}
		c++;
		
		
	}
	printf("%d\n",c);
 	return 0;
}
0