Submission #812619


Source Code Expand

import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int R = stdIn.nextInt();
		int G = stdIn.nextInt();
		int B = stdIn.nextInt();
		
		int Ra = 0;
		int Rb = 0;
		int Ga = 0;
		int Gb = 0;
		int Ba = 0;
		int Bb = 0;
		
		int ans = 100000000;
		
		for(int g = -350; g + G <= 350; g++){
			Ga = g; Gb = g + G - 1;
			if(Ga - 1 - R/2 < -100){
				Ra = (Ga - R) + 100;
				Rb = (Ga - 1) + 100;
			} else{
				Ra = -((R - 1)/2);
				Rb = R/2;
			}
			if(Gb + 1 + B/2 > 100){
				Ba = (Gb + 1) - 100;
				Bb = (Gb + B) - 100;
			} else{
				Ba = -((B - 1)/2);
				Bb = B/2;
			}
			int temp = func1(Ra, Rb) + func1(Ga, Gb) + func1(Ba, Bb);
			ans = (ans > temp ? temp : ans);
		}
		
		System.out.println(ans);
	}
	
	private static int func1(int int1, int int2){
		int ans = 0;
		int intAbs1 = int1 >= 0 ? int1 : -int1;
		int intAbs2 = int2 >= 0 ? int2 : -int2;
		
		if(int1 * int2 < 0){
			return (intAbs1*(intAbs1 + 1)/2 + intAbs2*(intAbs2 + 1)/2);
		} else{
			if(intAbs1 > intAbs2){
				return (intAbs1*(intAbs1 + 1)/2 - intAbs2*(intAbs2 - 1)/2);
			} else{
				return (intAbs2*(intAbs2 + 1)/2 - intAbs1*(intAbs1 - 1)/2);
			}
		}
		
	}
}

Submission Info

Submission Time
Task D - マーブル
User ste234689ado
Language Java (OpenJDK 1.7.0)
Score 100
Code Size 1265 Byte
Status AC
Exec Time 347 ms
Memory 19224 KiB

Judge Result

Set Name sub1 sub2 All
Score / Max Score 10 / 10 30 / 30 60 / 60
Status
AC × 29
AC × 57
AC × 82
Set Name Test Cases
sub1 sample_01_ABC.txt, test_ABC_01.txt, test_ABC_02.txt, test_ABC_03.txt, test_ABC_04.txt, test_ABC_05.txt, test_ABC_06.txt, test_ABC_07.txt, test_ABC_08.txt, test_ABC_09.txt, test_ABC_10.txt, test_ABC_11.txt, test_ABC_12.txt, test_ABC_13.txt, test_ABC_14.txt, test_ABC_15.txt, test_ABC_16.txt, test_ABC_17.txt, test_ABC_18.txt, test_ABC_19.txt, test_ABC_20.txt, test_ABC_21.txt, test_ABC_22.txt, test_ABC_23.txt, test_ABC_24.txt, test_ABC_25.txt, test_ABC_26.txt, test_ABC_27.txt, test_ABC_28.txt
sub2 sample_01_ABC.txt, sample_02_BC.txt, test_ABC_01.txt, test_ABC_02.txt, test_ABC_03.txt, test_ABC_04.txt, test_ABC_05.txt, test_ABC_06.txt, test_ABC_07.txt, test_ABC_08.txt, test_ABC_09.txt, test_ABC_10.txt, test_ABC_11.txt, test_ABC_12.txt, test_ABC_13.txt, test_ABC_14.txt, test_ABC_15.txt, test_ABC_16.txt, test_ABC_17.txt, test_ABC_18.txt, test_ABC_19.txt, test_ABC_20.txt, test_ABC_21.txt, test_ABC_22.txt, test_ABC_23.txt, test_ABC_24.txt, test_ABC_25.txt, test_ABC_26.txt, test_ABC_27.txt, test_ABC_28.txt, test_BC_29.txt, test_BC_30.txt, test_BC_31.txt, test_BC_32.txt, test_BC_33.txt, test_BC_34.txt, test_BC_35.txt, test_BC_36.txt, test_BC_37.txt, test_BC_38.txt, test_BC_39.txt, test_BC_40.txt, test_BC_41.txt, test_BC_42.txt, test_BC_43.txt, test_BC_44.txt, test_BC_45.txt, test_BC_46.txt, test_BC_47.txt, test_BC_48.txt, test_BC_49.txt, test_BC_50.txt, test_BC_51.txt, test_BC_52.txt, test_BC_53.txt, test_BC_54.txt, test_BC_55.txt
All test_ABC_01.txt, test_ABC_02.txt, test_ABC_03.txt, test_ABC_04.txt, test_ABC_05.txt, test_ABC_06.txt, test_ABC_07.txt, test_ABC_08.txt, test_ABC_09.txt, test_ABC_10.txt, test_ABC_11.txt, test_ABC_12.txt, test_ABC_13.txt, test_ABC_14.txt, test_ABC_15.txt, test_ABC_16.txt, test_ABC_17.txt, test_ABC_18.txt, test_ABC_19.txt, test_ABC_20.txt, test_ABC_21.txt, test_ABC_22.txt, test_ABC_23.txt, test_ABC_24.txt, test_ABC_25.txt, test_ABC_26.txt, test_ABC_27.txt, test_ABC_28.txt, test_BC_29.txt, test_BC_30.txt, test_BC_31.txt, test_BC_32.txt, test_BC_33.txt, test_BC_34.txt, test_BC_35.txt, test_BC_36.txt, test_BC_37.txt, test_BC_38.txt, test_BC_39.txt, test_BC_40.txt, test_BC_41.txt, test_BC_42.txt, test_BC_43.txt, test_BC_44.txt, test_BC_45.txt, test_BC_46.txt, test_BC_47.txt, test_BC_48.txt, test_BC_49.txt, test_BC_50.txt, test_BC_51.txt, test_BC_52.txt, test_BC_53.txt, test_BC_54.txt, test_BC_55.txt, test_C_56.txt, test_C_57.txt, test_C_58.txt, test_C_59.txt, test_C_60.txt, test_C_61.txt, test_C_62.txt, test_C_63.txt, test_C_64.txt, test_C_65.txt, test_C_66.txt, test_C_67.txt, test_C_68.txt, test_C_69.txt, test_C_70.txt, test_C_71.txt, test_C_72.txt, test_C_73.txt, test_C_74.txt, test_C_75.txt, test_C_76.txt, test_C_77.txt, test_C_78.txt, test_C_79.txt, test_C_80.txt, test_C_81.txt, test_C_82.txt
Case Name Status Exec Time Memory
sample_01_ABC.txt AC 324 ms 19160 KiB
sample_02_BC.txt AC 316 ms 19076 KiB
sample_03_C.txt AC 319 ms 19056 KiB
test_ABC_01.txt AC 323 ms 19084 KiB
test_ABC_02.txt AC 324 ms 19188 KiB
test_ABC_03.txt AC 324 ms 19160 KiB
test_ABC_04.txt AC 318 ms 19048 KiB
test_ABC_05.txt AC 319 ms 19072 KiB
test_ABC_06.txt AC 318 ms 19092 KiB
test_ABC_07.txt AC 317 ms 19072 KiB
test_ABC_08.txt AC 323 ms 19084 KiB
test_ABC_09.txt AC 322 ms 19104 KiB
test_ABC_10.txt AC 316 ms 19092 KiB
test_ABC_11.txt AC 313 ms 19052 KiB
test_ABC_12.txt AC 318 ms 19156 KiB
test_ABC_13.txt AC 315 ms 19052 KiB
test_ABC_14.txt AC 316 ms 19036 KiB
test_ABC_15.txt AC 321 ms 19144 KiB
test_ABC_16.txt AC 337 ms 19196 KiB
test_ABC_17.txt AC 339 ms 19056 KiB
test_ABC_18.txt AC 322 ms 19092 KiB
test_ABC_19.txt AC 323 ms 19100 KiB
test_ABC_20.txt AC 327 ms 19120 KiB
test_ABC_21.txt AC 342 ms 19076 KiB
test_ABC_22.txt AC 341 ms 19128 KiB
test_ABC_23.txt AC 321 ms 19188 KiB
test_ABC_24.txt AC 318 ms 19160 KiB
test_ABC_25.txt AC 347 ms 19068 KiB
test_ABC_26.txt AC 321 ms 19208 KiB
test_ABC_27.txt AC 319 ms 19060 KiB
test_ABC_28.txt AC 314 ms 19044 KiB
test_BC_29.txt AC 311 ms 19120 KiB
test_BC_30.txt AC 315 ms 19160 KiB
test_BC_31.txt AC 315 ms 19156 KiB
test_BC_32.txt AC 317 ms 19176 KiB
test_BC_33.txt AC 314 ms 19088 KiB
test_BC_34.txt AC 316 ms 19092 KiB
test_BC_35.txt AC 342 ms 19096 KiB
test_BC_36.txt AC 330 ms 19132 KiB
test_BC_37.txt AC 328 ms 19172 KiB
test_BC_38.txt AC 327 ms 19200 KiB
test_BC_39.txt AC 324 ms 19212 KiB
test_BC_40.txt AC 324 ms 19096 KiB
test_BC_41.txt AC 326 ms 19188 KiB
test_BC_42.txt AC 326 ms 19112 KiB
test_BC_43.txt AC 329 ms 19092 KiB
test_BC_44.txt AC 324 ms 19168 KiB
test_BC_45.txt AC 323 ms 19224 KiB
test_BC_46.txt AC 321 ms 19140 KiB
test_BC_47.txt AC 320 ms 19076 KiB
test_BC_48.txt AC 319 ms 19220 KiB
test_BC_49.txt AC 320 ms 19156 KiB
test_BC_50.txt AC 317 ms 19072 KiB
test_BC_51.txt AC 317 ms 19116 KiB
test_BC_52.txt AC 320 ms 18980 KiB
test_BC_53.txt AC 319 ms 19036 KiB
test_BC_54.txt AC 325 ms 19220 KiB
test_BC_55.txt AC 322 ms 19100 KiB
test_C_56.txt AC 317 ms 19032 KiB
test_C_57.txt AC 319 ms 19112 KiB
test_C_58.txt AC 318 ms 19084 KiB
test_C_59.txt AC 319 ms 19124 KiB
test_C_60.txt AC 319 ms 19132 KiB
test_C_61.txt AC 317 ms 19176 KiB
test_C_62.txt AC 318 ms 19132 KiB
test_C_63.txt AC 316 ms 19072 KiB
test_C_64.txt AC 318 ms 19148 KiB
test_C_65.txt AC 316 ms 19092 KiB
test_C_66.txt AC 324 ms 19124 KiB
test_C_67.txt AC 319 ms 19144 KiB
test_C_68.txt AC 318 ms 19100 KiB
test_C_69.txt AC 316 ms 19116 KiB
test_C_70.txt AC 315 ms 19104 KiB
test_C_71.txt AC 326 ms 19136 KiB
test_C_72.txt AC 321 ms 19028 KiB
test_C_73.txt AC 335 ms 19144 KiB
test_C_74.txt AC 320 ms 19168 KiB
test_C_75.txt AC 319 ms 19156 KiB
test_C_76.txt AC 319 ms 19096 KiB
test_C_77.txt AC 325 ms 19168 KiB
test_C_78.txt AC 339 ms 19120 KiB
test_C_79.txt AC 337 ms 19148 KiB
test_C_80.txt AC 342 ms 19188 KiB
test_C_81.txt AC 340 ms 19092 KiB
test_C_82.txt AC 331 ms 19212 KiB