結果
問題 |
No.3128 Isosceles Triangle
|
ユーザー |
|
提出日時 | 2025-04-26 01:36:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 381 ms / 2,500 ms |
コード長 | 953 bytes |
コンパイル時間 | 4,475 ms |
コンパイル使用メモリ | 257,344 KB |
実行使用メモリ | 36,864 KB |
最終ジャッジ日時 | 2025-04-26 01:36:16 |
合計ジャッジ時間 | 8,939 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> #include <algorithm> #include <atcoder/all> using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) #define all(x) begin(x), end(x) template <typename T> bool chmin(T& x, T y) { return x > y ? (x = y, true) : false; } template <typename T> bool chmax(T& x, T y) { return x < y ? (x = y, true) : false; } struct IOST { IOST() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20); } } IOST; void solve() { int n; cin >> n; vector<int> a(n); rep(i, 0, n) cin >> a[i]; map<int, ll> mp, smp; rep(i, 0, n) mp[a[i]]++; { ll tmp = 0; for (auto [x, y] : mp) { tmp += y; smp[x] = tmp; } } ll ans = 0; for (auto [x, y] : mp) { ll tmp = y * (y - 1) / 2; auto itr = smp.lower_bound(x * 2); itr--; tmp *= itr->second - y; ans += tmp; } cout << ans << "\n"; } int main() { int t = 1; // cin >> t; rep(i, 0, t) solve(); }