結果

問題 No.5 数字のブロック
ユーザー カルロスカルロス
提出日時 2015-07-14 10:52:04
言語 C90
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 718 bytes
コンパイル時間 129 ms
コンパイル使用メモリ 24,348 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 15:34:26
合計ジャッジ時間 1,322 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

void Quicksort(int data[], int left, int right){
    int l = left, r = right;
    int pivot = data[(left + right) / 2];
    int temp;

    while(1){
        while (data[l] < pivot) l++;
        while (pivot < data[r]) r--;
        if(r < l) break;

        temp = data[l];
        data[l] = data[r];
        data[r] = temp;

        l++, r--;
    }
    if(left < r)  Quicksort(data, left, r);
    if(l < right) Quicksort(data, l, right);
}

int main(void){
	int i, L, N;
	scanf("%d %d", &L, &N);

	int W[N];
	for(i=0;i<N;i++){
		scanf(" %d", &W[i]);
	}

	Quicksort(W, 0, N-1);

	i = 0;
	int sum = 0;
	while(1){
		sum += W[i];
		if (sum>L){
			printf("%d\n", i);
			break;
		}
		i++;
	}
	return 0;
}
0