結果

問題 No.91 赤、緑、青の石
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2017-01-12 04:14:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 121 ms / 5,000 ms
コード長 1,249 bytes
コンパイル時間 2,246 ms
コンパイル使用メモリ 74,584 KB
実行使用メモリ 56,520 KB
最終ジャッジ日時 2023-09-06 12:25:46
合計ジャッジ時間 7,212 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
55,772 KB
testcase_01 AC 112 ms
56,112 KB
testcase_02 AC 114 ms
55,564 KB
testcase_03 AC 119 ms
55,776 KB
testcase_04 AC 114 ms
55,896 KB
testcase_05 AC 112 ms
56,252 KB
testcase_06 AC 116 ms
56,488 KB
testcase_07 AC 115 ms
56,004 KB
testcase_08 AC 115 ms
55,968 KB
testcase_09 AC 119 ms
56,160 KB
testcase_10 AC 118 ms
56,144 KB
testcase_11 AC 118 ms
55,800 KB
testcase_12 AC 116 ms
56,024 KB
testcase_13 AC 114 ms
55,964 KB
testcase_14 AC 115 ms
56,180 KB
testcase_15 AC 115 ms
56,064 KB
testcase_16 AC 113 ms
56,020 KB
testcase_17 AC 116 ms
56,124 KB
testcase_18 AC 117 ms
55,896 KB
testcase_19 AC 117 ms
55,876 KB
testcase_20 AC 120 ms
56,380 KB
testcase_21 AC 116 ms
56,116 KB
testcase_22 AC 121 ms
55,872 KB
testcase_23 AC 116 ms
55,876 KB
testcase_24 AC 116 ms
56,520 KB
testcase_25 AC 118 ms
56,260 KB
testcase_26 AC 114 ms
56,292 KB
testcase_27 AC 118 ms
55,828 KB
testcase_28 AC 116 ms
56,084 KB
testcase_29 AC 120 ms
55,872 KB
testcase_30 AC 117 ms
53,976 KB
testcase_31 AC 116 ms
56,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int [] rgb = {sc.nextInt(),sc.nextInt(),sc.nextInt()};
        Arrays.sort(rgb);
        int min=rgb[0];
        int A = rgb[1]-rgb[0];
        int B = rgb[2]-rgb[0];
        int ans = min + sim(A,B);
        System.out.println(ans);
    }
    static int sim(int A, int B){
        int r = 0;
        while(A>=3||B>=3){
            if(A>B){
                int tmp=A;
                A=B;
                B=tmp;
            }
            if(B-A>=2){
                int k = (B-A)/2;
                if(k<=A){
                    B=B-3*k;
                    A=A-k;
                    r=r+k;
                }else{
                    r=r+A;
                    B=B-(3*A);
                    A=0;
                }
            }
            if(B-A<=1){
                int k=A/4;
                r=r+k*2;
                A=A-k*4;
                B=B-k*4;
            }
            if(A==0){
                int k=B/5;
                r=r+k;
                break;
            }else if(B>=3){
                A=A-1;
                B=B-3;
                r++;
            }
        }
        return r;
    }
}
0