結果
問題 |
No.91 赤、緑、青の石
|
ユーザー |
|
提出日時 | 2016-04-22 17:33:16 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 178 ms / 5,000 ms |
コード長 | 1,140 bytes |
コンパイル時間 | 3,646 ms |
コンパイル使用メモリ | 76,532 KB |
実行使用メモリ | 54,460 KB |
最終ジャッジ日時 | 2024-06-24 06:57:43 |
合計ジャッジ時間 | 9,957 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 |
ソースコード
package yukicorder; import java.util.Scanner; //TODO 見直し public class No_91 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int r = sc.nextInt(); int g = sc.nextInt(); int b = sc.nextInt(); System.out.println(solve(r,g,b)); } public static int solve(int r, int g, int b){ int basic = Math.min(Math.min(r,g),b); //各石の最低値 int red = r - basic; int green = g - basic; int blue = b - basic; int acce = basic; //暫定的なアクセサリーの数は変数basic while(true){ if(red == 0){ if(Math.max(green, blue) > 2){ if(blue > green){ blue -= 2; }else{ green -= 2; } }else{ break; } red++; } if(green == 0){ if(Math.max(red, blue) > 2){ if(blue > red){ blue -= 2; }else{ red -= 2; } }else{ break; } green++; } if(blue == 0){ if(Math.max(red, green) > 2){ if(red > green){ red -= 2; }else{ green -= 2; } }else{ break; } blue++; } red--; green--; blue--; acce++; } return acce; } }