結果
問題 | No.3128 Isosceles Triangle |
ユーザー |
![]() |
提出日時 | 2025-04-25 23:07:02 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 525 ms / 2,500 ms |
コード長 | 673 bytes |
コンパイル時間 | 3,647 ms |
コンパイル使用メモリ | 289,532 KB |
実行使用メモリ | 28,672 KB |
最終ジャッジ日時 | 2025-04-25 23:07:14 |
合計ジャッジ時間 | 10,794 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; std::cin >> n; std::vector<int> A(n); std::map<int, int> Mp; std::map<int, bool> vis; for (int i = 0; i < n; i++) { std::cin >> A[i]; Mp[A[i]]++; vis[A[i]] = false; } std::sort(A.begin(), A.end()); long long ans = 0; for (int i = 0; i < n; i++) { if (Mp[A[i]] == 1) { continue; } if (vis[A[i]]) { continue; } vis[A[i]] = true; int cnt = std::lower_bound(A.begin(), A.end(), 2 * A[i]) - A.begin(); ans += 1LL * (cnt - Mp[A[i]]) * Mp[A[i]] * (Mp[A[i]] - 1) / 2; } std::cout << ans << '\n'; }