結果

問題 No.1447 Greedy MtSaka
ユーザー hibit_athibit_at
提出日時 2021-03-31 14:37:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 863 bytes
コンパイル時間 733 ms
コンパイル使用メモリ 83,132 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-21 09:12:05
合計ジャッジ時間 1,760 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0