結果

問題 No.1447 Greedy MtSaka
ユーザー Super SolenoidSuper Solenoid
提出日時 2021-05-03 16:07:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 531 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 10,788 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2023-09-29 12:18:10
合計ジャッジ時間 2,672 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,808 KB
testcase_01 AC 17 ms
7,840 KB
testcase_02 AC 16 ms
7,804 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 15 ms
7,780 KB
testcase_06 AC 15 ms
7,952 KB
testcase_07 AC 15 ms
7,804 KB
testcase_08 AC 16 ms
7,804 KB
testcase_09 AC 15 ms
7,848 KB
testcase_10 AC 15 ms
7,808 KB
testcase_11 AC 16 ms
7,800 KB
testcase_12 AC 15 ms
7,908 KB
testcase_13 AC 15 ms
7,800 KB
testcase_14 AC 15 ms
7,780 KB
testcase_15 AC 16 ms
7,792 KB
testcase_16 AC 15 ms
7,928 KB
testcase_17 AC 14 ms
7,896 KB
testcase_18 AC 15 ms
7,896 KB
testcase_19 AC 15 ms
7,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
P = [[]  for _ in range(N)]

for i in range(N):
    P[i] = list(map(int, input().split()))
    
def calc_area(p, q, r):
    if p[0] - q[0] != 0:
        m = (p[1] - q[1])/(p[0] - q[0])
        y0 = p[1] - m * p[0]
        h = abs(-m*r[0] + r[1] -y0) / pow(1 + pow(m, 2), 0.5)
    else:
        h = abs(p[0] - r[0])
    
    b = pow(pow(p[0] - q[0], 2) + pow(p[1] - q[1], 2), 0.5)
    return b * h

A = 0

#必ず凸三角形なので
for i in range(N-2):
    A += calc_area(P[i + 1], P[i + 2], P[0])

print(int(A))
0