結果

問題 No.3128 Isosceles Triangle
ユーザー ケネン
提出日時 2025-04-25 23:08:09
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 890 bytes
コンパイル時間 2,493 ms
コンパイル使用メモリ 209,132 KB
実行使用メモリ 38,680 KB
最終ジャッジ日時 2025-04-25 23:08:21
合計ジャッジ時間 10,493 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 25 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;

set<ll> s, thr;
map<ll, ll> m;
vector<ll> v, cnt;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);

  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
    s.insert(x);
    m[x]++;
  }
  vector<ll> p(s.begin(), s.end());
  cnt = vector<ll>(s.size()+1);

  ll sum = 0;
  for (int i = 0; i < v.size(); i++) {
    int vidx = lower_bound(p.begin(), p.end(), v[i]) - p.begin();
    int idx = upper_bound(p.begin(), p.end(), v[i]/2) - p.begin();
    if (idx <= vidx) cnt[idx]++, cnt[vidx]--, cnt[vidx+1]++;
    else cnt[idx]++;
  }

  for (int i = 0; i < cnt.size(); i++) {
    // cout << cnt[i] << " ";
    if (i) cnt[i] += cnt[i-1];
    int w = p[i];
    sum += m[w]*(m[w]-1)/2*cnt[i];
  }
  cout << sum;
}
0