結果

問題 No.21 平均の差
ユーザー TLwiegehttTLwiegehtt
提出日時 2015-07-08 05:11:40
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 868 bytes
コンパイル時間 364 ms
コンパイル使用メモリ 26,980 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 09:30:55
合計ジャッジ時間 1,067 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 0 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 0 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <math.h>

int num[15];
int stack[20];
int scnt=0;
int gAve=0;

void saiki(int digit, int k){
	int i;
	if(k == 0 && digit == 0){
		int s;
		int tAve;
		int ssum = 0;
		double minAve = 9999999.0;
		double maxAve = 0.0;
		
		for(s=0;s<scnt;s++){
			double ag = 0.0;
			for(i=0;i<stack[s];i++){
				ag = ag + (1.0*num[ssum+i]);
			}
			
			ag = ag/(1.0*stack[s]);
			
			if(minAve > ag ){
				minAve = ag;
			}
			if(maxAve < ag ){
				maxAve = ag;
			}
			
			ssum += stack[s];
		}
		
		tAve = (int)ceil(maxAve-minAve);
		if(gAve < tAve){
			gAve = tAve;
		}
		return;
	}
	
	for(i=1;i<=digit;i++){
		stack[scnt] = i;
		scnt++;
		saiki(digit-i, k-1);
		scnt--;
	}
	
	return;
}

int main(void){
	int i,n,k;
	
	scanf("%d", &n);
	scanf("%d", &k);
	for(i=0;i<n;i++){
		scanf("%d", &num[i]);
	}
	
	saiki(n,k);
	
	
	printf("%d\n", gAve);
	return 0;
}
0