結果

問題 No.5 数字のブロック
ユーザー sekiya9311sekiya9311
提出日時 2016-03-05 05:22:47
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 178 ms / 5,000 ms
コード長 600 bytes
コンパイル時間 345 ms
コンパイル使用メモリ 24,548 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-11 14:45:19
合計ジャッジ時間 3,073 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 0 ms
4,380 KB
testcase_03 AC 70 ms
4,384 KB
testcase_04 AC 45 ms
4,380 KB
testcase_05 AC 114 ms
4,384 KB
testcase_06 AC 49 ms
4,380 KB
testcase_07 AC 32 ms
4,384 KB
testcase_08 AC 61 ms
4,384 KB
testcase_09 AC 8 ms
4,380 KB
testcase_10 AC 134 ms
4,380 KB
testcase_11 AC 32 ms
4,380 KB
testcase_12 AC 75 ms
4,380 KB
testcase_13 AC 110 ms
4,384 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 119 ms
4,384 KB
testcase_17 AC 162 ms
4,384 KB
testcase_18 AC 140 ms
4,380 KB
testcase_19 AC 178 ms
4,380 KB
testcase_20 AC 0 ms
4,384 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 0 ms
4,384 KB
testcase_23 AC 0 ms
4,384 KB
testcase_24 AC 1 ms
4,384 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 0 ms
4,384 KB
testcase_28 AC 0 ms
4,384 KB
testcase_29 AC 44 ms
4,380 KB
testcase_30 AC 11 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
void smaller_sort(int *a,int cnt);
int main(void){
    int l,n,w[10000],i,cnt,sum;
    scanf("%d",&l);
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&w[i]);
    }
    smaller_sort(w,n);
    sum=0;
    cnt=0;
    for(i=0;i<n;i++){
        sum+=w[i];
        if(sum>l){
            break;
        }else{
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}

void smaller_sort(int *a,int cnt){
	int i,j,buf;
	for(i=0;i<cnt-1;i++){
		for(j=cnt-1;j>i;j--){
			if(*(a+j)<*(a+j-1)){
				buf=*(a+j-1);
				*(a+j-1)=*(a+j);
				*(a+j)=buf;
			}
		}
	}
}
0