結果

問題 No.1447 Greedy MtSaka
ユーザー tktk_snsn
提出日時 2021-03-31 20:20:56
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 535 bytes
コンパイル時間 669 ms
コンパイル使用メモリ 72,832 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-15 07:45:18
合計ジャッジ時間 1,523 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    int ans = 0;
    int x, y; cin >> x >> y;

    vector<int> xp(n), yp(n);
    for(int i=0; i<n-1; ++i) cin >> xp[i] >> yp[i];
    for(int i=0; i<n-2; ++i){
        int tx, ty, sx, sy;
        sx = xp[i]-x;
        sy = yp[i]-y;
        tx = xp[i+1]-x;
        ty = yp[i+1]-y;
        ans += abs(sx*ty - sy*tx);
    }
    cout << ans << endl;
}
0