結果

問題 No.461 三角形はいくつ?
ユーザー titia
提出日時 2023-09-19 03:28:25
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,052 bytes
コンパイル時間 1,365 ms
コンパイル使用メモリ 113,848 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 16:07:05
合計ジャッジ時間 4,293 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main() {
    vector<vector<long double>> L(3, vector<long double>(1, 0.0));

    int N;
    cin >> N;

    for (int i = 0; i < N; ++i) {
        int p;
        long double a, b;
        cin >> p >> a >> b;
        L[p].push_back(b / (a + b));
    }

    sort(L[0].begin(), L[0].end());
    sort(L[1].begin(), L[1].end());
    sort(L[2].begin(), L[2].end());

    int ANS = 0;
    set<long double> SET(L[2].begin(), L[2].end());

    for (long double x : L[0]) {
        for (long double y : L[1]) {
            if (x + y > 1.0) {
                break;
            }
            long double MAX = max(x, y);
            auto it = lower_bound(L[2].begin(), L[2].end(), 1.0 - MAX);
            int k = distance(L[2].begin(), it);
            ANS += k;
            long double z = x + y;
            if (z < 1.0 - MAX && SET.find(1.0 - z) != SET.end()) {
                ANS -= 1;
            }
        }
    }

    cout << ANS << endl;

    return 0;
}
0