結果
問題 |
No.1447 Greedy MtSaka
|
ユーザー |
![]() |
提出日時 | 2021-04-01 07:48:56 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 899 bytes |
コンパイル時間 | 848 ms |
コンパイル使用メモリ | 103,296 KB |
実行使用メモリ | 18,304 KB |
最終ジャッジ日時 | 2024-12-16 10:13:46 |
合計ジャッジ時間 | 1,833 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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); ; } }