結果

問題 No.461 三角形はいくつ?
ユーザー りあんりあん
提出日時 2016-12-09 15:58:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 331 ms / 5,000 ms
コード長 1,496 bytes
コンパイル時間 1,868 ms
コンパイル使用メモリ 174,324 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-06 18:31:04
合計ジャッジ時間 6,588 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 106 ms
6,948 KB
testcase_06 AC 57 ms
6,940 KB
testcase_07 AC 67 ms
6,944 KB
testcase_08 AC 48 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 15 ms
6,940 KB
testcase_11 AC 77 ms
6,944 KB
testcase_12 AC 37 ms
6,940 KB
testcase_13 AC 121 ms
6,940 KB
testcase_14 AC 113 ms
6,940 KB
testcase_15 AC 120 ms
6,940 KB
testcase_16 AC 10 ms
6,940 KB
testcase_17 AC 10 ms
6,944 KB
testcase_18 AC 221 ms
6,940 KB
testcase_19 AC 226 ms
6,944 KB
testcase_20 AC 122 ms
6,940 KB
testcase_21 AC 119 ms
6,940 KB
testcase_22 AC 116 ms
6,944 KB
testcase_23 AC 25 ms
6,940 KB
testcase_24 AC 22 ms
6,940 KB
testcase_25 AC 30 ms
6,940 KB
testcase_26 AC 30 ms
6,944 KB
testcase_27 AC 5 ms
6,944 KB
testcase_28 AC 5 ms
6,940 KB
testcase_29 AC 312 ms
6,944 KB
testcase_30 AC 282 ms
6,944 KB
testcase_31 AC 320 ms
6,944 KB
testcase_32 AC 331 ms
6,944 KB
testcase_33 AC 5 ms
6,944 KB
testcase_34 AC 5 ms
6,944 KB
testcase_35 AC 5 ms
6,940 KB
testcase_36 AC 40 ms
6,944 KB
testcase_37 AC 35 ms
6,940 KB
testcase_38 AC 37 ms
6,940 KB
testcase_39 AC 33 ms
6,944 KB
testcase_40 AC 39 ms
6,944 KB
testcase_41 AC 37 ms
6,940 KB
testcase_42 AC 110 ms
6,940 KB
testcase_43 AC 114 ms
6,944 KB
testcase_44 AC 111 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

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 (long double a : lines[0])
    {
        for (long double 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;
                long 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;
                long 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