結果

問題 No.461 三角形はいくつ?
ユーザー りあんりあん
提出日時 2016-12-09 15:57:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,472 bytes
コンパイル時間 1,487 ms
コンパイル使用メモリ 172,868 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-06 18:29:48
合計ジャッジ時間 6,537 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 123 ms
5,376 KB
testcase_06 AC 61 ms
5,376 KB
testcase_07 AC 77 ms
5,376 KB
testcase_08 AC 52 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 16 ms
5,376 KB
testcase_11 AC 84 ms
5,376 KB
testcase_12 AC 43 ms
5,376 KB
testcase_13 AC 142 ms
5,376 KB
testcase_14 AC 133 ms
5,376 KB
testcase_15 AC 148 ms
5,376 KB
testcase_16 AC 9 ms
5,376 KB
testcase_17 AC 8 ms
5,376 KB
testcase_18 AC 242 ms
5,376 KB
testcase_19 AC 254 ms
5,376 KB
testcase_20 AC 149 ms
5,376 KB
testcase_21 AC 139 ms
5,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 21 ms
5,376 KB
testcase_26 AC 20 ms
5,376 KB
testcase_27 AC 4 ms
5,376 KB
testcase_28 AC 5 ms
5,376 KB
testcase_29 AC 365 ms
5,376 KB
testcase_30 AC 318 ms
5,376 KB
testcase_31 AC 350 ms
5,376 KB
testcase_32 AC 366 ms
5,376 KB
testcase_33 AC 5 ms
5,376 KB
testcase_34 AC 5 ms
5,376 KB
testcase_35 AC 4 ms
5,376 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    long double eps = 1e-17L;
    cin >> n;
    vector<long double> lines[3];
    for (int i = 0; i < 3; i++)
    {
        lines[i].emplace_back(0.0);
    }
    for (int i = 0; i < n; i++)
    {
        int p, a, b;
        cin >> p >> a >> b;
        lines[p].emplace_back(b / (long double)(a + b));
    }

    for (int i = 0; i < 3; i++)
        sort(lines[i].begin(), lines[i].end());

    long long ans = 0;
    for (auto a : lines[0])
    {
        for (auto b : lines[1])
        {
            if (a + b > 1 + eps) continue;

            int ok = 0, ng = lines[2].size();
            while (ok < ng - 1)
            {
                int m = (ok + ng) >> 1;
                double c = lines[2][m];
                if (a + c < 1 + eps && b + c < 1 + eps)
                    ok = m;
                else
                    ng = m;
            }
            ans += ok + 1;
            int l = 0, r = lines[2].size() - 1;
            while (1)
            {
                int m = (l + r) >> 1;
                double c = lines[2][m];
                if (abs(a + b + c - 1) < eps)
                {
                    --ans;
                    break;
                }
                if (l >= r) break;

                if (a + b + c < 1)
                    l = m + 1;
                else
                    r = m - 1;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}
0