結果

問題 No.1447 Greedy MtSaka
ユーザー simansiman
提出日時 2021-07-16 06:37:05
言語 Ruby
(3.3.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 214 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 11,484 KB
実行使用メモリ 15,336 KB
最終ジャッジ日時 2023-09-18 19:13:53
合計ジャッジ時間 4,689 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,120 KB
testcase_01 AC 84 ms
15,300 KB
testcase_02 AC 82 ms
15,168 KB
testcase_03 AC 83 ms
15,336 KB
testcase_04 AC 84 ms
15,120 KB
testcase_05 AC 84 ms
15,284 KB
testcase_06 AC 84 ms
15,084 KB
testcase_07 AC 82 ms
15,040 KB
testcase_08 AC 82 ms
15,276 KB
testcase_09 AC 82 ms
15,116 KB
testcase_10 AC 81 ms
15,120 KB
testcase_11 AC 81 ms
15,312 KB
testcase_12 AC 81 ms
15,244 KB
testcase_13 AC 81 ms
15,260 KB
testcase_14 AC 82 ms
15,048 KB
testcase_15 AC 80 ms
15,056 KB
testcase_16 AC 81 ms
15,036 KB
testcase_17 AC 82 ms
15,072 KB
testcase_18 AC 81 ms
15,152 KB
testcase_19 AC 81 ms
15,124 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
P = N.times.map { gets.split.map(&:to_i) }

x1, y1 = P[0]
ans = 0

1.upto(N - 2) do |i|
  x2, y2 = P[i]
  x3, y3 = P[i + 1]

  ans += ((x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3)).abs
end

puts ans
0