結果

問題 No.3128 Isosceles Triangle
コンテスト
ユーザー tokitsukaze
提出日時 2025-04-28 20:22:28
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 196 ms / 2,500 ms
コード長 538 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,316 ms
コンパイル使用メモリ 221,592 KB
実行使用メモリ 16,724 KB
最終ジャッジ日時 2026-07-10 09:24:50
合計ジャッジ時間 5,251 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3fLL;
const int MAX=1e7+10;
int main()
{
	int n,i,x;
	ll ans,cnt;
	scanf("%d",&n);
	map<int,int> mp;
	vector<int> res;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&x);
		mp[x]++;
		res.push_back(x);
	}
	sort(res.begin(),res.end());
	ans=0;
	for(auto &it:mp)
	{
		cnt=lower_bound(res.begin(),res.end(),it.first*2)-res.begin();
		cnt-=it.second;
		ans+=cnt*(it.second*(it.second-1)/2);
	}
	printf("%lld\n",ans);
	return 0;
}
0