結果

問題 No.91 赤、緑、青の石
ユーザー リチウムリチウム
提出日時 2014-12-07 22:43:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 44 ms / 5,000 ms
コード長 1,657 bytes
コンパイル時間 3,143 ms
コンパイル使用メモリ 75,148 KB
実行使用メモリ 49,568 KB
最終ジャッジ日時 2023-09-06 12:08:21
合計ジャッジ時間 5,723 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
48,916 KB
testcase_01 AC 40 ms
49,020 KB
testcase_02 AC 44 ms
49,024 KB
testcase_03 AC 40 ms
48,928 KB
testcase_04 AC 42 ms
46,964 KB
testcase_05 AC 41 ms
49,568 KB
testcase_06 AC 42 ms
49,264 KB
testcase_07 AC 41 ms
49,180 KB
testcase_08 AC 41 ms
49,408 KB
testcase_09 AC 41 ms
48,980 KB
testcase_10 AC 40 ms
49,292 KB
testcase_11 AC 39 ms
48,888 KB
testcase_12 AC 39 ms
49,068 KB
testcase_13 AC 41 ms
48,944 KB
testcase_14 AC 40 ms
48,912 KB
testcase_15 AC 40 ms
48,884 KB
testcase_16 AC 40 ms
49,048 KB
testcase_17 AC 41 ms
49,016 KB
testcase_18 AC 41 ms
49,068 KB
testcase_19 AC 40 ms
49,092 KB
testcase_20 AC 40 ms
49,364 KB
testcase_21 AC 40 ms
48,956 KB
testcase_22 AC 40 ms
48,848 KB
testcase_23 AC 41 ms
48,984 KB
testcase_24 AC 41 ms
49,424 KB
testcase_25 AC 42 ms
49,180 KB
testcase_26 AC 40 ms
49,168 KB
testcase_27 AC 41 ms
49,048 KB
testcase_28 AC 43 ms
49,012 KB
testcase_29 AC 41 ms
47,044 KB
testcase_30 AC 40 ms
48,928 KB
testcase_31 AC 40 ms
49,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.lang.Math.*;
public class ppp {
			
  public static void main(String[] args) {
	  MyScanner sc=new MyScanner();
	 int r=sc.nextInt();
	 int g=sc.nextInt();
	 int b=sc.nextInt();
	 int c[]={r,g,b};
	 int ans=0;
		Arrays.sort(c);
		ans+=c[0];
		c[2]-=c[0];
		c[1]-=c[0];
		c[0]-=c[0];
		int x=Math.min(c[1],(c[2]-c[1])/2);
		ans+=x;
		c[2]-=x*3;
		c[1]-=x;
		while(c[2]>2){
			if(c[1]==0){
				ans+=c[2]/5;
				break;
			}
			else if(c[1]>3){
				int L=c[1]/4;
				ans+=L*2;
				c[1]-=L*4;
				c[2]-=L*4;
			}
			else{
				c[2]-=2;
                c[0]++;
				Arrays.sort(c);
				if(c[0]>0){
					ans+=c[0];
					c[2]-=c[0];
					c[1]-=c[0];
					c[0]=0;
				}
			}
		}
		
		
	 System.out.println(ans);
	 
	 
  }
}

class MyScanner {
	int nextInt() {
		try {
			int c = System.in.read();
			while (c != '-' && (c < '0' || '9' < c))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = System.in.read();
			} while ('0' <= c && c <= '9');
			return res;
		} catch (Exception e) {
			return -1;
		}
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	String next() {
		try {
			StringBuilder res = new StringBuilder("");
			int c = System.in.read();
			while (Character.isWhitespace(c))
				c = System.in.read();
			do {
				res.append((char) c);
			} while (!Character.isWhitespace(c = System.in.read()));
			return res.toString();
		} catch (Exception e) {
			return null;
		}
	}
}
0