結果

問題 No.1447 Greedy MtSaka
ユーザー ApassApass
提出日時 2021-03-31 14:57:03
言語 Java19
(openjdk 21)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 3,139 ms
コンパイル使用メモリ 72,628 KB
実行使用メモリ 56,268 KB
最終ジャッジ日時 2023-08-21 11:35:43
合計ジャッジ時間 6,807 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,900 KB
testcase_01 AC 121 ms
53,628 KB
testcase_02 AC 122 ms
56,168 KB
testcase_03 AC 123 ms
55,840 KB
testcase_04 AC 123 ms
55,672 KB
testcase_05 AC 124 ms
55,708 KB
testcase_06 AC 123 ms
55,620 KB
testcase_07 AC 124 ms
56,004 KB
testcase_08 AC 130 ms
53,772 KB
testcase_09 AC 123 ms
55,848 KB
testcase_10 AC 125 ms
55,760 KB
testcase_11 AC 122 ms
56,084 KB
testcase_12 AC 123 ms
55,844 KB
testcase_13 AC 123 ms
55,952 KB
testcase_14 AC 126 ms
55,852 KB
testcase_15 AC 123 ms
55,640 KB
testcase_16 AC 123 ms
56,268 KB
testcase_17 AC 121 ms
55,896 KB
testcase_18 AC 120 ms
55,896 KB
testcase_19 AC 123 ms
55,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class C_GreedyMtSaka {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        int[] Y = new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
            Y[i] = sc.nextInt();
        }
        System.out.println(-polygonAreaTwice(X, Y, N));
    }

    static long polygonAreaTwice(int[] X, int[] Y, int n) {
        long area = 0L;

        for (int i = 0, j = n - 1; i < n; j = i, i++) {
            area += (long) (X[j] + X[i]) * (Y[j] - Y[i]);
        }
        return area;
    }
}
0