結果

問題 No.178 美しいWhitespace (1)
ユーザー tsunabittsunabit
提出日時 2019-05-17 01:20:43
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 797 bytes
コンパイル時間 3,753 ms
コンパイル使用メモリ 76,380 KB
実行使用メモリ 60,320 KB
最終ジャッジ日時 2023-10-17 07:07:35
合計ジャッジ時間 9,904 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
57,320 KB
testcase_01 AC 135 ms
57,284 KB
testcase_02 AC 136 ms
57,428 KB
testcase_03 AC 135 ms
57,552 KB
testcase_04 AC 215 ms
59,560 KB
testcase_05 AC 216 ms
59,600 KB
testcase_06 AC 212 ms
59,884 KB
testcase_07 AC 213 ms
59,972 KB
testcase_08 AC 213 ms
60,212 KB
testcase_09 AC 213 ms
60,068 KB
testcase_10 AC 212 ms
60,300 KB
testcase_11 WA -
testcase_12 AC 213 ms
59,840 KB
testcase_13 AC 216 ms
59,788 KB
testcase_14 AC 215 ms
59,608 KB
testcase_15 AC 213 ms
59,956 KB
testcase_16 AC 218 ms
60,100 KB
testcase_17 AC 217 ms
59,744 KB
testcase_18 WA -
testcase_19 AC 216 ms
59,836 KB
testcase_20 AC 216 ms
59,588 KB
testcase_21 AC 213 ms
59,792 KB
testcase_22 AC 204 ms
59,848 KB
testcase_23 AC 214 ms
59,764 KB
testcase_24 AC 217 ms
60,076 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<Integer> l = new ArrayList<Integer>();
        
        // 𝑎+4𝑏+2𝑐
        for(int i = 0; i < n; i++) {
            // a + 4b + 2c
        	l.add(s.nextInt() + (4 * s.nextInt()));
        }
        Collections.sort(l, Collections.reverseOrder());
        long o = 0;
        for(int v : l) {
        	o += l.get(0) - v;
        }
        if(o % 2 == 0) {
        	System.out.println(o / 2);
        }else {
        	System.out.println(-1);
        }
    }
}
0