結果

問題 No.1447 Greedy MtSaka
ユーザー ApassApass
提出日時 2021-03-31 14:57:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 3,592 ms
コンパイル使用メモリ 74,212 KB
実行使用メモリ 41,504 KB
最終ジャッジ日時 2024-05-08 16:55:59
合計ジャッジ時間 6,900 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
40,208 KB
testcase_01 AC 130 ms
41,092 KB
testcase_02 AC 126 ms
41,412 KB
testcase_03 AC 130 ms
41,352 KB
testcase_04 AC 126 ms
40,820 KB
testcase_05 AC 117 ms
40,000 KB
testcase_06 AC 126 ms
41,188 KB
testcase_07 AC 124 ms
41,124 KB
testcase_08 AC 132 ms
41,296 KB
testcase_09 AC 122 ms
41,192 KB
testcase_10 AC 115 ms
40,140 KB
testcase_11 AC 126 ms
41,128 KB
testcase_12 AC 131 ms
41,232 KB
testcase_13 AC 130 ms
41,324 KB
testcase_14 AC 117 ms
40,212 KB
testcase_15 AC 130 ms
41,504 KB
testcase_16 AC 116 ms
40,104 KB
testcase_17 AC 119 ms
40,588 KB
testcase_18 AC 127 ms
41,480 KB
testcase_19 AC 116 ms
40,172 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