結果
| 問題 | No.3128 Isosceles Triangle |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-27 13:23:39 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 166 ms / 2,500 ms |
| + 897µs | |
| コード長 | 838 bytes |
| 記録 | |
| コンパイル時間 | 2,793 ms |
| コンパイル使用メモリ | 195,432 KB |
| 実行使用メモリ | 26,812 KB |
| 最終ジャッジ日時 | 2026-10-27 13:24:30 |
| 合計ジャッジ時間 | 8,751 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge7_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <algorithm>
#include <utility>
#include <map>
#include <vector>
using namespace std;
using ll = long long;
using pil = pair<int, ll>;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N; cin>>N;
map<int, ll> M;
for (int i=0;i<N;i++){
int A; cin>>A;
M[A]++;
}
int K = M.size();
vector<pil> edge;
vector<ll> S(K+1, 0);
for (auto p: M){
edge.push_back(p);
}
sort(edge.begin(), edge.end());
for (int i=1;i<=K;i++) S[i]=S[i-1]+edge[i-1].second;
ll ans = 0;
int right = 0;
for (int left=0;left<K;left++){
while(right<K && edge[right].first<2*edge[left].first) right++;
ans += edge[left].second*(edge[left].second-1)/2LL*(S[right]-edge[left].second);
}
cout << ans << "\n";
return 0;
}