結果
| 問題 |
No.1447 Greedy MtSaka
|
| コンテスト | |
| ユーザー |
hibit_at
|
| 提出日時 | 2021-03-31 14:37:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 863 bytes |
| コンパイル時間 | 910 ms |
| コンパイル使用メモリ | 84,896 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-14 19:17:48 |
| 合計ジャッジ時間 | 1,525 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define all(A) A.begin(), A.end()
typedef long long ll;
double heron(pair<int,int> start,pair<int,int> target1,pair<int,int> target2){
target1.first -= start.first;
target1.second -= start.second;
target2.first -= start.first;
target2.second -= start.second;
return abs(target1.first*target2.second-target2.first*target1.second);
}
int main() {
int n;
cin >> n;
vector<pair<int,int>> xy(n);
rep(i,n){
int x,y;
cin >> x >> y;
xy[i] = make_pair(x,y);
}
int ans = 0;
rep(i,n-2){
ans += heron(xy[0],xy[i+1],xy[i+2]);
}
cout << ans << endl;
}
hibit_at