結果

問題 No.1447 Greedy MtSaka
ユーザー Flkanjin
提出日時 2021-04-01 18:10:46
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,647 bytes
コンパイル時間 1,378 ms
コンパイル使用メモリ 139,760 KB
最終ジャッジ日時 2025-01-20 05:04:14
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int MOD2 = 998'244'353;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}










int main(){
    int N; std::cin >> N;
    long long S{};
    long long X0, Y0; std::cin >> X0 >> Y0;
    std::vector<long long> x(N-1), y(N-1);
    {
        int X, Y;
        for(int i{0}, i_len{N-1}; i < i_len; ++i){
            std::cin >> X >> Y;
            x[i] = X - X0; y[i] = Y - Y0;
            if(i){
                S += x[(i-1) % (N-1)]*y[i] - x[i]*y[(i-1) % (N-1)];
            }
        }
    }
    S += x[N-2]*y[0] - x[N-2]*y[0];
    std::cout << std::abs(S) << std::endl;
    return 0;
}
0