結果
問題 | No.178 美しいWhitespace (1) |
ユーザー | tak |
提出日時 | 2018-08-05 10:03:47 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,533 bytes |
コンパイル時間 | 2,651 ms |
コンパイル使用メモリ | 91,456 KB |
実行使用メモリ | 39,440 KB |
最終ジャッジ日時 | 2024-09-19 18:01:06 |
合計ジャッジ時間 | 6,188 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 77 ms
38,304 KB |
testcase_01 | AC | 79 ms
38,312 KB |
testcase_02 | AC | 70 ms
38,056 KB |
testcase_03 | AC | 77 ms
37,804 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 98 ms
39,232 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 95 ms
39,028 KB |
testcase_12 | AC | 97 ms
38,976 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 96 ms
38,852 KB |
testcase_19 | WA | - |
testcase_20 | AC | 96 ms
39,168 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 106 ms
39,092 KB |
testcase_24 | AC | 97 ms
38,900 KB |
ソースコード
import java.io.PrintWriter; import java.util.*; import java.io.*; import java.util.function.*; public class Main { public static void main(String[] args) { new Main().stream(); } final FastIO io = new FastIO(); final PrintWriter out = new PrintWriter(System.out); void stream(){ solve(); out.flush(); } int f(int[] a, int[] b){ int[] sums = new int[a.length]; REP(a.length,i-> sums[i] = a[i] + b[i] * 4); long oddNum = Arrays.stream(sums).filter(i -> i % 2 == 0).count(); if(oddNum==0||oddNum==sums.length){ int max = Arrays.stream(sums).max().getAsInt(); int diffSum = Arrays.stream(sums).map(i -> max - i ).sum(); return diffSum / 2; }else{ return -1; } } void solve() { int N = io.Int(); int[] a = new int[N]; int[] b = new int[N]; REP(N, i->{ a[i] = io.Int(); b[i] = io.Int(); }); System.out.println(f(a,b)); } void FOR(int a, int b, Consumer<Integer>act) { for(int i = a; i < b; ++i) act.accept(i); } void REP(int a, Consumer<Integer>act) { FOR(0, a, act); } } class FastIO{ private final InputStream in = System.in; private final byte[] buffer = new byte[1<<12]; private int ptr = 0, buffLen = 0; private boolean hasNextByte () { if(ptr < buffLen) return true; ptr = 0; try{ buffLen = in.read(buffer); } catch (IOException e){ e.printStackTrace(); } return buffLen > 0; } private int readByte () { return hasNextByte()? buffer[ptr++] : -1; } private boolean isPrintableChar (int c) { return 33 <= c && c <= 126; } //ASCII private void skipUnprintable () { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; } private boolean hasNext () { skipUnprintable(); return hasNextByte();} private String next () { if(!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)){ sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public String String () { return next(); } public char Char () { return next().charAt(0);} public int Int () { return Integer.parseInt(next());} public long Long () { return Long.parseLong(next());} public double Double () { return Double.parseDouble(next());} }