結果

問題 No.91 赤、緑、青の石
ユーザー TLwiegehttTLwiegehtt
提出日時 2015-07-16 23:07:17
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 77 ms / 5,000 ms
コード長 812 bytes
コンパイル時間 478 ms
コンパイル使用メモリ 26,504 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 12:13:22
合計ジャッジ時間 2,354 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
4,376 KB
testcase_01 AC 35 ms
4,376 KB
testcase_02 AC 22 ms
4,380 KB
testcase_03 AC 40 ms
4,380 KB
testcase_04 AC 20 ms
4,380 KB
testcase_05 AC 48 ms
4,380 KB
testcase_06 AC 6 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 0 ms
4,376 KB
testcase_10 AC 0 ms
4,376 KB
testcase_11 AC 14 ms
4,376 KB
testcase_12 AC 42 ms
4,380 KB
testcase_13 AC 46 ms
4,376 KB
testcase_14 AC 31 ms
4,380 KB
testcase_15 AC 50 ms
4,380 KB
testcase_16 AC 0 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 0 ms
4,376 KB
testcase_19 AC 0 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 0 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 0 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 77 ms
4,376 KB
testcase_26 AC 72 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 53 ms
4,376 KB
testcase_31 AC 70 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int min(int a, int b){
	if(a<b){return a;}
	return b;
}

void sortRGB(int *rgb){
	int i,j;
	for(i=0;i<3;i++){
		for(j=i+1;j<3;j++){
			if(rgb[i] < rgb[j]){
				int tmp = rgb[i];
				rgb[i] = rgb[j];
				rgb[j] = tmp;
			}
		}
	}
	return;
}

int main(void){
	int ans = 0;
	int rgb[3];
	scanf("%d %d %d", &rgb[0], &rgb[1], &rgb[2]);
	
	sortRGB(rgb);
	
	while(1){
		
		ans += rgb[2];
		rgb[0] -= rgb[2];
		rgb[1] -= rgb[2];
		rgb[2] -= rgb[2];
		
		sortRGB(rgb);
		
		if(rgb[1] == 0){
			int tmp = (rgb[0]/5);
			rgb[1] += tmp;
			rgb[2] += tmp;
			rgb[0] -= tmp*2*2;
		}else{
			int tmp = 0;
			if(rgb[0]>2){tmp=1;}
			rgb[2] += tmp;
			rgb[0] -= tmp*2;
			
		}
		
		sortRGB(rgb);
		
		if(rgb[2] == 0){
			break;
		}
	}
	
	printf("%d\n", ans);
	return 0;
}
0