結果

問題 No.3128 Isosceles Triangle
ユーザー t98slider
提出日時 2025-04-30 03:29:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 67 ms / 2,500 ms
コード長 492 bytes
コンパイル時間 2,510 ms
コンパイル使用メモリ 196,496 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-04-30 03:29:51
合計ジャッジ時間 5,542 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto &&v : a) cin >> v;
    sort(a.begin(), a.end());
    ll ans = 0;
    for(int i = 0, j = 0, p; i < n; ){
        p = i;
        while(i < n && a[i] == a[p]) i++;
        while(j < n && a[j] < a[p] * 2) j++;
        ll c = i - p;
        ans += c * (c - 1) / 2 * (j - c);
    }
    cout << ans << '\n';
}
0