結果

問題 No.1447 Greedy MtSaka
ユーザー glretoglreto
提出日時 2021-04-01 18:15:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,157 bytes
コンパイル時間 1,595 ms
コンパイル使用メモリ 105,596 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 20:54:44
合計ジャッジ時間 2,005 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
#include<map>
#include<random>
#include<complex>
#include<math.h>
#include<functional>
#include<stack>
#include<queue>
#include<set>
#include <cassert>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n-1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;
const int inf = 0x3fffffff;
using Real = ld;
using Point = complex< Real >;
const Real EPS = 1e-8, PI = acos(-1);
inline bool eq(Real a, Real b) { return fabs(b - a) < EPS; }
Point operator*(const Point& p, const Real& d) { return Point(real(p) * d, imag(p) * d); }
istream& operator>>(istream& is, Point& p) {
    Real a, b; is >> a >> b; p = Point(a, b);
    return is;
}
ostream& operator<<(ostream& os, Point& p) { return os << fixed << setprecision(10) << p.real() << " " << p.imag(); }
// 点 p を反時計回りに theta 回転
Point rotate(Real theta, const Point& p) {
    return Point(cos(theta) * p.real() - sin(theta) * p.imag(), sin(theta) * p.real() + cos(theta) * p.imag());
}
namespace std {
    bool operator<(const Point& a, const Point& b) {
        return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
    }
}
using Points = vector< Point >;
using Polygon = vector< Point >;
Real cross(const Point& a, const Point& b) { return real(a) * imag(b) - imag(a) * real(b); }
Real area(const Polygon& p) {
    Real A = 0;
    for (int i = 0; i < p.size(); ++i) {
        A += cross(p[i], p[(i + 1) % p.size()]);
    }return A * 0.5;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n; ll ans = 0; vector<ll> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    rep(i, n) {
        ans += x[i] * y[(i + 1) % n] - y[i] * x[(i + 1) % n];
    }cout << ans << endl;
}
0