結果

問題 No.5 数字のブロック
ユーザー ふっぴーふっぴー
提出日時 2017-03-30 16:22:57
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 811 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 29,788 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-21 08:42:45
合計ジャッジ時間 1,556 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <stdlib.h>
#define INF 1000000000;

void Qsort(int x[], int left, int right);
void swap(int x[],int i,int j);

int main(void){
	int l,n;
	scanf("%d %d",&l,&n);
	int w[n];
	int i;
	for(i=0;i<n;i++){
		scanf("%d",&w[i]);
	}
	Qsort(w,0,n-1);
	int cnt=0;
	i=0;
	while(l-w[i]>=0){
		cnt++;
		l=l-w[i];
		i++;
	}
	printf("%d\n",cnt);
	return 0;
}

void Qsort(int x[], int left, int right){
	int i,j;
	int pivot;
	i=left;
	j=right;
	pivot=x[(left+right)/2];
	while(1){
		while(x[i]<pivot)
			i++;
		while(pivot<x[j])
			j--;
		if(i>=j)
			break;
		swap(x,i,j);
		i++;
		j--;
	}
	if(left<i-1)
		Qsort(x,left,i-1);
	if(j+1<right)
		Qsort(x,j+1,right);
}

void swap(int x[],int i,int j){
	int temp;
	temp=x[i];
	x[i]=x[j];
	x[j]=temp;
}
0