結果
| 問題 |
No.1447 Greedy MtSaka
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-20 21:52:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 823 bytes |
| コンパイル時間 | 960 ms |
| コンパイル使用メモリ | 116,808 KB |
| 最終ジャッジ日時 | 2025-01-23 03:23:45 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
int main() {
int32_t n;
cin >> n;
vector<pair<int32_t, int32_t>> xys(n);
for (auto &&xy : xys) {
cin >> xy.first >> xy.second;
}
int64_t ans = 0;
for (auto i = 1; i < n - 1; ++i) {
int64_t x0 = xys[i].first - xys[0].first,
y0 = xys[i].second - xys[0].second;
int64_t x1 = xys[i + 1].first - xys[0].first,
y1 = xys[i + 1].second - xys[0].second;
ans += abs(x0 * y1 - x1 * y0);
}
cout << ans << endl;
return 0;
}