Submission #3717357
Source Code Expand
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); // 整数の入力 int r = sc.nextInt(); int g = sc.nextInt(); int b = sc.nextInt(); //GreenとRedの間(中心を除く)の和 int sumGR = (g-1)/2 + (r-1)/2; int sumGB = (g-1)/2 + (b-1)/2; int result = 0; int tmp,hogered; int hogegreen = -100; //間の和が100未満かどうかの4通りで場合分け if(sumGR < 100 && sumGB < 100){ //それぞれ干渉しない result = count(r) + count(g) + count(b); } else { //両方あふれて、左右にずれる result = countOperation(g, -300 ,0) + countOperation(r, -300-r, -100) + countOperation(b, -300+g, 100); for(int greenLeft = -300; greenLeft < 0; ++greenLeft){ int redLeft = greenLeft - r; int blueLeft = greenLeft + g; tmp = countOperation(g, greenLeft ,0) + countOperation(r, redLeft, -100) + countOperation(b, blueLeft, 100); if(tmp < result){ result = tmp; hogegreen = greenLeft; } } } System.out.println(result); // System.out.println(hogegreen); } //展開するときの個数を入れると回数を返す public static int count(int num){ if(num == 2){ return 1; } else if(num == 1){ return 0; } else { return count(num-1) + num/2; } } //展開するときの個数と左端、中心を入れると回数を返す public static int countOperation(int num, int left, int center){ int result = 0; for(int i = 0; i < num; ++i){ result += Math.abs(center - left - i); } return result; } }
Submission Info
Submission Time | |
---|---|
Task | A - 流行 |
User | teiwa18 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 1650 Byte |
Status | RE |
Exec Time | 108 ms |
Memory | 25044 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 0 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 00_sample_00.txt, max_1000000.txt, min_0.txt, rand_133007.txt, rand_171937.txt, rand_172717.txt, rand_232508.txt, rand_242450.txt, rand_246841.txt, rand_269046.txt, rand_320433.txt, rand_435534.txt, rand_50616.txt, rand_537196.txt, rand_565439.txt, rand_601980.txt, rand_622146.txt, rand_624081.txt, rand_678601.txt, rand_696476.txt, rand_762274.txt, rand_798714.txt, rand_821336.txt, rand_85323.txt, rand_859632.txt, rand_921203.txt, rand_934508.txt, rand_993594.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | RE | 96 ms | 18644 KB |
max_1000000.txt | RE | 98 ms | 19540 KB |
min_0.txt | RE | 99 ms | 19412 KB |
rand_133007.txt | RE | 98 ms | 19284 KB |
rand_171937.txt | RE | 96 ms | 18772 KB |
rand_172717.txt | RE | 97 ms | 21844 KB |
rand_232508.txt | RE | 99 ms | 17620 KB |
rand_242450.txt | RE | 99 ms | 23764 KB |
rand_246841.txt | RE | 100 ms | 23124 KB |
rand_269046.txt | RE | 97 ms | 19284 KB |
rand_320433.txt | RE | 98 ms | 21588 KB |
rand_435534.txt | RE | 98 ms | 19796 KB |
rand_50616.txt | RE | 97 ms | 20948 KB |
rand_537196.txt | RE | 101 ms | 20052 KB |
rand_565439.txt | RE | 99 ms | 20692 KB |
rand_601980.txt | RE | 98 ms | 19668 KB |
rand_622146.txt | RE | 98 ms | 19028 KB |
rand_624081.txt | RE | 97 ms | 19796 KB |
rand_678601.txt | RE | 98 ms | 16976 KB |
rand_696476.txt | RE | 99 ms | 21460 KB |
rand_762274.txt | RE | 98 ms | 19924 KB |
rand_798714.txt | RE | 98 ms | 19796 KB |
rand_821336.txt | RE | 98 ms | 19284 KB |
rand_85323.txt | RE | 97 ms | 20948 KB |
rand_859632.txt | RE | 98 ms | 19284 KB |
rand_921203.txt | RE | 108 ms | 18772 KB |
rand_934508.txt | RE | 99 ms | 25044 KB |
rand_993594.txt | RE | 102 ms | 23124 KB |