結果

問題 No.3128 Isosceles Triangle
ユーザー ldsyb
提出日時 2025-04-25 23:07:38
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 265 ms / 2,500 ms
コード長 701 bytes
コンパイル時間 6,323 ms
コンパイル使用メモリ 334,048 KB
実行使用メモリ 21,760 KB
最終ジャッジ日時 2025-04-25 23:07:50
合計ジャッジ時間 10,916 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif

int main()
{
    int64_t n;
    cin >> n;
    vector<int64_t> as(n);
    for (auto &&a : as)
    {
        cin >> a;
    }

    ranges::sort(as);

    map<int64_t, int64_t> mp;
    for (auto &&a : as)
    {
        mp[a]++;
    }

    int64_t ans = 0;

    for (auto [k, v] : mp)
    {
        if (2 <= v)
        {
            auto itr = ranges::lower_bound(as, 2 * k);
            int64_t t = distance(as.begin(), itr);
            t -= v;

            ans += v * (v - 1) / 2 * t;
        }
    }

    cout << ans << endl;

    return 0;
}
0