結果

問題 No.178 美しいWhitespace (1)
ユーザー 37zigen37zigen
提出日時 2016-03-31 15:48:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 200 ms / 2,000 ms
コード長 599 bytes
コンパイル時間 1,965 ms
コンパイル使用メモリ 74,152 KB
実行使用メモリ 57,148 KB
最終ジャッジ日時 2024-04-10 06:47:51
合計ジャッジ時間 7,398 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
54,212 KB
testcase_01 AC 119 ms
53,880 KB
testcase_02 AC 108 ms
52,996 KB
testcase_03 AC 119 ms
53,860 KB
testcase_04 AC 193 ms
56,520 KB
testcase_05 AC 192 ms
56,600 KB
testcase_06 AC 192 ms
56,648 KB
testcase_07 AC 192 ms
56,568 KB
testcase_08 AC 188 ms
56,248 KB
testcase_09 AC 194 ms
56,456 KB
testcase_10 AC 190 ms
56,804 KB
testcase_11 AC 188 ms
56,580 KB
testcase_12 AC 185 ms
57,092 KB
testcase_13 AC 188 ms
56,928 KB
testcase_14 AC 190 ms
57,148 KB
testcase_15 AC 191 ms
56,644 KB
testcase_16 AC 194 ms
56,480 KB
testcase_17 AC 192 ms
57,128 KB
testcase_18 AC 186 ms
56,824 KB
testcase_19 AC 179 ms
56,768 KB
testcase_20 AC 183 ms
56,796 KB
testcase_21 AC 180 ms
56,492 KB
testcase_22 AC 181 ms
56,632 KB
testcase_23 AC 191 ms
56,676 KB
testcase_24 AC 200 ms
56,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder178;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long[] a=new long[n];//space
		long[] b=new long[n];//tab
		long[] width=new long[n];
		long max=0;
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
			width[i]=a[i]+4*b[i];
			max=Math.max(width[i], max);
		}		
		long ans=0;
		for(int i=0;i<n;i++){
			width[i]=max-width[i];
			if(width[i]%2==1){
				System.out.println(-1);
				return;
			}else{
				ans+=width[i]/2;
			}
		}
		System.out.println(ans);
	}
}
0