結果

問題 No.2012 Largest Triangle
ユーザー 259_Momone259_Momone
提出日時 2022-07-15 23:06:16
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,260 bytes
コンパイル時間 4,154 ms
コンパイル使用メモリ 269,340 KB
実行使用メモリ 6,880 KB
最終ジャッジ日時 2023-09-10 05:49:52
合計ジャッジ時間 12,896 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 147 ms
6,272 KB
testcase_17 AC 148 ms
6,268 KB
testcase_18 AC 147 ms
6,136 KB
testcase_19 AC 146 ms
6,140 KB
testcase_20 AC 147 ms
6,160 KB
testcase_21 AC 144 ms
6,140 KB
testcase_22 AC 146 ms
6,248 KB
testcase_23 AC 147 ms
6,192 KB
testcase_24 AC 147 ms
6,472 KB
testcase_25 AC 146 ms
6,092 KB
testcase_26 AC 340 ms
6,856 KB
testcase_27 AC 307 ms
6,880 KB
testcase_28 AC 337 ms
6,732 KB
testcase_29 AC 329 ms
6,692 KB
testcase_30 AC 337 ms
6,844 KB
testcase_31 AC 146 ms
6,200 KB
testcase_32 AC 147 ms
6,144 KB
testcase_33 AC 148 ms
6,248 KB
testcase_34 AC 148 ms
6,204 KB
testcase_35 AC 147 ms
6,164 KB
testcase_36 AC 3 ms
4,380 KB
testcase_37 AC 3 ms
4,376 KB
testcase_38 AC 3 ms
4,380 KB
testcase_39 AC 3 ms
4,380 KB
testcase_40 AC 3 ms
4,376 KB
testcase_41 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/extc++.h>

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<pair<long, long>> points(N);
    for(auto&& [x, y] : points)cin >> x >> y;
    sort(begin(points), end(points));
    const auto cross_product{[](auto&& i, auto&& j, auto&& k){
        auto&& [x0, y0]{i};
        auto&& [x1, y1]{j};
        auto&& [x2, y2]{k};
        const auto a{x0 * y1 + x1 * y2 + x2 * y0}, b{x0 * y2 + x1 * y0 + x2 * y1};
        return (a < b) - (a > b);
    }};
    vector<pair<long, long>> upper, lower;
    for(const auto& now : points){
        while(size(upper) > 1 && cross_product(upper.end()[-2], upper.end()[-1], now) < 0)upper.pop_back();
        upper.emplace_back(now);
    }
    for(const auto& now : points){
        while(size(lower) > 1 && cross_product(lower.end()[-2], lower.end()[-1], now) > 0)lower.pop_back();
        lower.emplace_back(now);
    }
    reverse(begin(lower), end(lower));
    if(upper.front() == lower.back())lower.pop_back();
    if(lower.front() == upper.back())upper.pop_back();
    upper.insert(end(upper), begin(lower), end(lower));
    long ans{};
    for(const auto& [x, y] : upper)for(const auto& [z, w] : upper)ans = max(ans, x * w - y * z);
    cout << ans << endl;
    return 0;
}
0