結果

問題 No.5 数字のブロック
ユーザー yoshikiriyoshikiri
提出日時 2016-07-15 22:30:00
言語 C90
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 608 bytes
コンパイル時間 754 ms
コンパイル使用メモリ 21,376 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 04:39:51
合計ジャッジ時間 3,432 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 0 ms
6,944 KB
testcase_03 AC 69 ms
6,940 KB
testcase_04 AC 45 ms
6,944 KB
testcase_05 AC 110 ms
6,940 KB
testcase_06 AC 49 ms
6,940 KB
testcase_07 AC 34 ms
6,940 KB
testcase_08 AC 62 ms
6,944 KB
testcase_09 AC 8 ms
6,944 KB
testcase_10 AC 132 ms
6,944 KB
testcase_11 AC 32 ms
6,944 KB
testcase_12 AC 76 ms
6,940 KB
testcase_13 AC 112 ms
6,944 KB
testcase_14 RE -
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 112 ms
6,940 KB
testcase_17 AC 156 ms
6,944 KB
testcase_18 AC 147 ms
6,940 KB
testcase_19 AC 181 ms
6,944 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 0 ms
6,944 KB
testcase_23 AC 0 ms
6,944 KB
testcase_24 AC 0 ms
6,944 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 43 ms
6,940 KB
testcase_30 AC 12 ms
6,944 KB
testcase_31 RE -
testcase_32 AC 1 ms
6,940 KB
testcase_33 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:27:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |         scanf("%d%d",&Len,&N);
      |         ^~~~~~~~~~~~~~~~~~~~~
main.c:31:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |                 scanf("%d",&Wid[i]);
      |                 ^~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

void sortarray(int n,int array[]){
	int i,j,min,max,temp;
	int sarray[n];

	for(i=0;i<n;i++){

		for(j=0;j<n;j++){
			if(array[j]<min){
				min = array[j];
				temp = j;
			}
			if(i>0) continue;
			if(array[j]>max) max = array[j];
		}
		sarray[i] = min;
		array[temp] = max + 1;
		min = max;
	}
	for(i=0;i<n;i++) array[i] = sarray[i];
}

int main(void){
	int i,ans=0,Len,N;

	scanf("%d%d",&Len,&N);
	int Wid[N];

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

	sortarray(N,Wid);
	
	for(i=0;i<N;i++){
		if(Len>=Wid[i]){
			Len -= Wid[i];
			ans++;
		}
	}
	printf("%d\n",ans);

	return 0;
}
0