結果

問題 No.91 赤、緑、青の石
ユーザー bal4ubal4u
提出日時 2019-06-22 18:35:32
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 777 bytes
コンパイル時間 424 ms
コンパイル使用メモリ 29,296 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-06 12:42:38
合計ジャッジ時間 1,471 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

// yukicoder: No.91 赤、緑、青の石
// 2019.6.22 bal4u

#include <stdio.h>
#include <stdlib.h>

int cmp(const void *a, const void *b) { return *(int *)b - *(int *)a; }

int bsch(int A, int B)
{
	int a, b, l = 0, r = B;

    while (l+1 < r) {
        b = (l + r) >> 1;
		a = (B - b) / 3;
		if (a + 3*b > A) r = b;
		else l = b;
    }
	return l
	;
}

int main()
{
	int i, A[3], ans;

	for (i = 0; i < 3; i++) scanf("%d", A+i);
	qsort(A, 3, sizeof(int), cmp);
	ans = A[2], A[0] -= ans, A[1] -= ans;
	
	if (A[1] > 0) {
		if (A[0] >= 3*A[1]) ans += A[1], A[0] -= A[1]*3, A[1] = 0;
		else if (A[0] >= 3) {
			int a, b;
			b = bsch(A[0], A[1]);
			a = (A[1] - b)/3;
			ans += a + b;
			A[0] -= a + 3*b, A[1] -= 3*a + b;
		}
	}

	ans += A[0]/5;
	printf("%d\n", ans);
	return 0;
}
0