結果

問題 No.91 赤、緑、青の石
コンテスト
ユーザー rana
提出日時 2021-09-14 15:27:09
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 662 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 187 ms
コンパイル使用メモリ 42,240 KB
最終ジャッジ日時 2026-02-22 07:59:43
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 5 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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