結果

問題 No.91 赤、緑、青の石
ユーザー suppy193suppy193
提出日時 2016-11-10 13:37:29
言語 C90
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 811 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 21,248 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-05-04 01:20:17
合計ジャッジ時間 7,346 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
6,528 KB
testcase_01 AC 13 ms
5,376 KB
testcase_02 AC 8 ms
5,376 KB
testcase_03 AC 14 ms
5,376 KB
testcase_04 AC 7 ms
5,376 KB
testcase_05 AC 16 ms
5,376 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:28:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |         scanf("%d%d%d", &s[0], &s[1], &s[2]);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

void swap(int *a, int *b)
{
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
}

void sort(int *s)
{
	if(s[0] > s[1]){
		swap(&s[0], &s[1]);
	}
	if(s[1] > s[2]){
		swap(&s[1], &s[2]);
	}
	if(s[0] > s[1]){
		swap(&s[0], &s[1]);
	}
}

int main(void) {
	int i;
	int a = 0;
	int s[3];
	scanf("%d%d%d", &s[0], &s[1], &s[2]);
	sort(s);
	//printf("%d %d %d:%d\n\n", s[0], s[1], s[2], a);

	a += s[0];
	s[2] -= s[0];
	s[1] -= s[0];
	s[0] = 0;
	sort(s);
	//printf("%d %d %d:%d\n", s[0], s[1], s[2], a);

	while(1){
		if((s[0] == 0 && s[1] == 0 && s[2] < 5) 
		|| (s[0] == 0 && s[1] == 1 && s[2] < 3)
		|| (s[0] == 0 && s[1] == 2 && s[2] == 2)){
			break;
		}
		a++;
		s[0] = 0;
		s[1]--;
		s[2] -= 3;
		sort(s);
		//printf("%d %d %d:%d\n\n", s[0], s[1], s[2], a);
	}
	
	printf("%d\n", a);
		
	return 0;
}
0