結果

問題 No.178 美しいWhitespace (1)
ユーザー tsunabittsunabit
提出日時 2019-05-19 23:37:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 895 bytes
コンパイル時間 3,727 ms
コンパイル使用メモリ 76,644 KB
実行使用メモリ 60,272 KB
最終ジャッジ日時 2023-10-17 08:02:12
合計ジャッジ時間 9,660 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 132 ms
57,204 KB
testcase_02 AC 130 ms
57,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 209 ms
60,208 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 211 ms
60,212 KB
testcase_12 AC 209 ms
60,256 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 215 ms
59,992 KB
testcase_19 WA -
testcase_20 AC 219 ms
60,144 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 213 ms
60,272 KB
testcase_24 AC 212 ms
59,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Scanner;
import java.util.Collections;

public class No178 {
    public static void main(String[] args) {
        // 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        ArrayList<Long> l = new ArrayList<Long>();
        
        // 𝑎+4𝑏+2𝑐
        for(int i = 0; i < n; i++) {
            // a + 4b + 2c
        	Long temp = s.nextLong() + (4 * s.nextLong());
        	l.add(temp);
        }
        Collections.sort(l, Collections.reverseOrder());
        long o = 0;
        for(Long v : l) {
        	if((l.get(0) - v) % 2 != 0) {
        		System.out.println(-1);
        		return;
        	}
        }
        if(o % 2 == 0) {
        	System.out.println(o / 2);
        }else {
        	System.out.println(-1);
        }
    }
}
0