結果

問題 No.91 赤、緑、青の石
ユーザー ranarana
提出日時 2021-09-14 15:27:09
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 662 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 29,672 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-09-09 12:35:58
合計ジャッジ時間 1,610 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int max(int x, int y) {
    if (x < y) return y;
    return x;
}

int main() {
    int r, g, b;
    int start = 0, end = 1e9;
    scanf("%d %d %d", &r, &g, &b);

    while (end - start > 1) {
        int mid = (start + end) / 2;
        bool ok = true;
        int amari = max(0, r - mid) / 2 + max(0, g - mid) / 2 + max(0, b - mid) / 2;
        int husoku = max(0, mid - r) + max(0, mid - g) + max(0, mid - b);

        if (amari * 2 < husoku) ok = false;

        if (ok) start = mid;
        else end = mid;
    }

    printf("%d\n", start);
    return (0);
}
0