結果

問題 No.1120 Strange Teacher
ユーザー ApassApass
提出日時 2020-07-22 22:33:36
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,276 bytes
コンパイル時間 5,122 ms
コンパイル使用メモリ 76,376 KB
実行使用メモリ 62,308 KB
最終ジャッジ日時 2023-09-05 02:25:07
合計ジャッジ時間 11,435 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
50,968 KB
testcase_01 AC 63 ms
50,928 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 275 ms
60,280 KB
testcase_06 AC 275 ms
61,872 KB
testcase_07 AC 298 ms
60,196 KB
testcase_08 AC 282 ms
59,588 KB
testcase_09 AC 44 ms
49,548 KB
testcase_10 AC 262 ms
58,456 KB
testcase_11 AC 245 ms
60,388 KB
testcase_12 AC 240 ms
59,092 KB
testcase_13 AC 279 ms
60,084 KB
testcase_14 AC 300 ms
60,076 KB
testcase_15 AC 277 ms
60,160 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 58 ms
50,736 KB
testcase_19 AC 285 ms
62,308 KB
testcase_20 AC 44 ms
49,504 KB
testcase_21 AC 44 ms
49,548 KB
testcase_22 AC 44 ms
49,552 KB
testcase_23 AC 57 ms
50,732 KB
testcase_24 AC 273 ms
60,272 KB
testcase_25 AC 44 ms
49,656 KB
testcase_26 AC 58 ms
50,736 KB
testcase_27 WA -
testcase_28 AC 57 ms
50,732 KB
testcase_29 AC 43 ms
49,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.math.MathContext;
import java.util.*;

public class StrangeTeacher {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    private static StringTokenizer st;

    private static int readInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }

    public static void main(String[] args) throws IOException {
        pw.println(solve());
        pw.close();
    }

    private static long solve() throws IOException {
        int N = readInt();
        long[] A = new long[N];
        for (int i = 0; i < N; i++) A[i] = readInt();
        for (int i = 0; i < N; i++) A[i] -= readInt();

        if (N == 2) {
            if (A[0] + A[1] == 0) return Math.abs(A[0]);
            else return -1;
        }

        for (int i = 1; i < N; i++) {
            if ((A[i] - A[0]) % 2 != 0) return -1;
        }

        long sum = Arrays.stream(A).sum();

        if (sum < 0 || sum % (N - 2) != 0 || (sum - A[0]) % 2 != 0) return -1;

        return sum / (N - 2);
    }
}
0