結果

問題 No.1120 Strange Teacher
ユーザー ApassApass
提出日時 2020-07-22 22:48:37
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,310 bytes
コンパイル時間 5,588 ms
コンパイル使用メモリ 76,656 KB
実行使用メモリ 62,424 KB
最終ジャッジ日時 2023-09-05 02:56:53
合計ジャッジ時間 12,260 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
50,708 KB
testcase_01 AC 61 ms
50,584 KB
testcase_02 AC 75 ms
52,212 KB
testcase_03 AC 134 ms
55,916 KB
testcase_04 AC 268 ms
60,284 KB
testcase_05 AC 276 ms
60,200 KB
testcase_06 AC 282 ms
62,336 KB
testcase_07 AC 279 ms
60,188 KB
testcase_08 AC 274 ms
59,688 KB
testcase_09 AC 57 ms
50,552 KB
testcase_10 AC 263 ms
61,524 KB
testcase_11 AC 263 ms
62,168 KB
testcase_12 AC 279 ms
61,816 KB
testcase_13 AC 270 ms
60,556 KB
testcase_14 AC 272 ms
59,448 KB
testcase_15 AC 307 ms
57,652 KB
testcase_16 WA -
testcase_17 AC 281 ms
60,164 KB
testcase_18 AC 59 ms
50,856 KB
testcase_19 AC 313 ms
62,424 KB
testcase_20 AC 43 ms
49,520 KB
testcase_21 AC 43 ms
49,456 KB
testcase_22 AC 57 ms
50,676 KB
testcase_23 AC 58 ms
50,732 KB
testcase_24 AC 293 ms
60,324 KB
testcase_25 AC 43 ms
49,380 KB
testcase_26 AC 57 ms
49,084 KB
testcase_27 AC 57 ms
50,728 KB
testcase_28 AC 57 ms
50,628 KB
testcase_29 AC 57 ms
50,848 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;
        }

        long sum = Arrays.stream(A).sum();
        if (sum < 0 || sum % (N - 2) != 0) return -1;
        long operation = sum / (N-2);

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

        return operation;
    }
}
0