結果
問題 | No.91 赤、緑、青の石 |
ユーザー |
![]() |
提出日時 | 2016-05-26 05:18:05 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 179 ms / 5,000 ms |
コード長 | 1,230 bytes |
コンパイル時間 | 2,078 ms |
コンパイル使用メモリ | 78,084 KB |
実行使用メモリ | 54,228 KB |
最終ジャッジ日時 | 2024-06-24 06:58:49 |
合計ジャッジ時間 | 7,380 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 |
ソースコード
import java.util.Scanner;public class Main {public static void main(String[] args) {try (Scanner scan = new Scanner(System.in)) {int v[] = new int[3];v[0] = Integer.parseInt(scan.next());v[1] = Integer.parseInt(scan.next());v[2] = Integer.parseInt(scan.next());while(true) {if(v[0] == v[1] && v[0] == v[2]) {System.out.println(v[0]);return;}int maxI = 0;int minI = 0;int max = v[maxI];int min = v[minI];for(int i=1; i<3; i++) {if(max < v[i]) {max = v[i];maxI = i;}if(min > v[i]) {min = v[i];minI = i;}}if(max - min == 1) {System.out.println(min);return;}v[maxI] -= 2;v[minI] += 1;}}}}