結果

問題 No.178 美しいWhitespace (1)
ユーザー mits58mits58
提出日時 2016-07-02 15:19:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 280 ms / 2,000 ms
コード長 470 bytes
コンパイル時間 2,373 ms
コンパイル使用メモリ 74,372 KB
実行使用メモリ 43,804 KB
最終ジャッジ日時 2024-04-20 05:50:56
合計ジャッジ時間 8,394 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
41,392 KB
testcase_01 AC 141 ms
41,372 KB
testcase_02 AC 144 ms
41,428 KB
testcase_03 AC 128 ms
41,620 KB
testcase_04 AC 215 ms
43,304 KB
testcase_05 AC 202 ms
43,248 KB
testcase_06 AC 219 ms
43,504 KB
testcase_07 AC 280 ms
43,424 KB
testcase_08 AC 209 ms
43,120 KB
testcase_09 AC 216 ms
43,732 KB
testcase_10 AC 222 ms
43,268 KB
testcase_11 AC 203 ms
43,652 KB
testcase_12 AC 209 ms
43,792 KB
testcase_13 AC 205 ms
43,780 KB
testcase_14 AC 214 ms
43,592 KB
testcase_15 AC 210 ms
43,712 KB
testcase_16 AC 213 ms
43,724 KB
testcase_17 AC 197 ms
43,440 KB
testcase_18 AC 219 ms
43,220 KB
testcase_19 AC 191 ms
43,600 KB
testcase_20 AC 202 ms
43,804 KB
testcase_21 AC 198 ms
43,640 KB
testcase_22 AC 226 ms
43,640 KB
testcase_23 AC 221 ms
43,164 KB
testcase_24 AC 207 ms
43,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int n=sc.nextInt();
			long[] c=new long[n];
			long max=0;
			for(int i=0;i<n;i++){
				c[i]=sc.nextInt()+sc.nextInt()*4;
				max=Math.max(c[i],max);
			}
			long ans=0;
			for(int i=0;i<n;i++){
				if(ans==-1) break;
				if((max-c[i])%2==1) ans=-1;
				else ans+=(max-c[i])/2;
			}
			System.out.println(ans);
		}
	}
}
0