結果

問題 No.1447 Greedy MtSaka
ユーザー bluemeganebluemegane
提出日時 2021-04-01 07:48:56
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 899 bytes
コンパイル時間 2,263 ms
コンパイル使用メモリ 60,708 KB
実行使用メモリ 22,940 KB
最終ジャッジ日時 2023-08-22 13:03:37
合計ジャッジ時間 3,896 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
20,612 KB
testcase_01 AC 57 ms
20,900 KB
testcase_02 AC 56 ms
20,664 KB
testcase_03 AC 56 ms
20,860 KB
testcase_04 AC 57 ms
20,612 KB
testcase_05 AC 57 ms
22,660 KB
testcase_06 AC 56 ms
20,856 KB
testcase_07 AC 56 ms
18,580 KB
testcase_08 AC 58 ms
20,900 KB
testcase_09 AC 57 ms
20,708 KB
testcase_10 AC 57 ms
18,764 KB
testcase_11 AC 56 ms
18,412 KB
testcase_12 AC 57 ms
22,940 KB
testcase_13 AC 56 ms
20,560 KB
testcase_14 AC 56 ms
20,852 KB
testcase_15 AC 56 ms
20,660 KB
testcase_16 AC 57 ms
20,620 KB
testcase_17 AC 57 ms
22,760 KB
testcase_18 AC 57 ms
20,720 KB
testcase_19 AC 57 ms
20,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using static System.Math;
using System;

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        n--;
        var x = new int[n];
        var y = new int[n];
        string[] line = Console.ReadLine().Trim().Split(' ');
        var x0 = int.Parse(line[0]);
        var y0 = int.Parse(line[1]);
        for (int i = 0; i < n; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            x[i] = int.Parse(line[0]) - x0;
            y[i] = int.Parse(line[1]) - y0;
        }
        getAns(n, x, y);
    }
    static long calc(int[] x, int[] y, int i)
    {
        long ans = Abs(x[i] * y[i + 1] - x[i + 1] * y[i]);
        return ans;
    }
    static void getAns(int n, int[] x, int[] y)
    {
        long ans = 0;
        for (int i = 0; i < n - 1; i++) ans += calc(x, y, i);
        Console.WriteLine(ans); ;
    }
}
0