結果
| 問題 |
No.3128 Isosceles Triangle
|
| コンテスト | |
| ユーザー |
SnowBeenDiding
|
| 提出日時 | 2025-04-25 21:44:16 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 151 ms / 2,500 ms |
| コード長 | 713 bytes |
| コンパイル時間 | 6,358 ms |
| コンパイル使用メモリ | 333,556 KB |
| 実行使用メモリ | 17,792 KB |
| 最終ジャッジ日時 | 2025-04-25 21:44:58 |
| 合計ジャッジ時間 | 9,783 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <atcoder/all>
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
using namespace atcoder;
using namespace std;
typedef long long ll;
void solve() {
int n;
cin >> n;
vector<int> a(n);
rep(i, 0, n) cin >> a[i];
sort(a.begin(), a.end());
ll ans = 0;
map<int, int> ma;
rep(i, 0, n) ma[a[i]]++;
int cnt = 0;
a.emplace_back(2e9 + 10);
for (auto [k, v] : ma) {
while (a[cnt] < k * 2) {
cnt++;
}
ans += (ll)(cnt - v) * v * (v - 1) / 2;
}
cout << ans << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
while (t--) {
solve();
}
}
SnowBeenDiding