結果

問題 No.91 赤、緑、青の石
ユーザー リチウム
提出日時 2014-12-07 21:31:09
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,570 bytes
コンパイル時間 3,923 ms
コンパイル使用メモリ 78,644 KB
実行使用メモリ 52,276 KB
最終ジャッジ日時 2024-06-11 17:22:25
合計ジャッジ時間 6,385 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 11 WA * 17
権限があれば一括ダウンロードができます

ソースコード

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]>3){
			if(c[1]==0){
				ans+=c[2]/5;
				break;
			}
			else if(c[1]>3){
				ans+=(c[1]/4)*2;
				c[1]-=(c[1]/4)*4;
				c[2]-=(c[1]/4)*4;
			}
			else{
				c[2]-=3;
				c[1]--;
				ans++;
				Arrays.sort(c);
			}
		}
		
		
	 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