結果
問題 |
No.1882 Areas of Triangle
|
ユーザー |
![]() |
提出日時 | 2024-07-18 22:54:27 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 921 bytes |
コンパイル時間 | 1,357 ms |
コンパイル使用メモリ | 119,456 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-18 22:54:30 |
合計ジャッジ時間 | 2,252 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 24 |
ソースコード
#define PROBLEM "https://yukicoder.me/problems/no/1882" #include <iostream> #include <vector> #include <ranges> #include <algorithm> template <class Lambda> auto binarySearch(long long ok, long long ng, const Lambda& is_ok) { while(std::abs(ok - ng) > 1) { long long mid = (ok + ng) >> 1; (is_ok(mid) ? ok : ng) = mid; } return ok; } using ll = long long; using std::cout; using std::cin; constexpr char endl = '\n'; struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing; signed main() { ll n, x; cin >> n >> x; std::vector<ll> a(n); for(int i = 0; i < n; ++i) { cin >> a[i]; } std::ranges::sort(a); ll ans = 0; for(const auto& val : a) { auto idx = binarySearch(n, -1, [&](ll mid) { return val * a[mid] >= (x << 1); }); ans += n - idx; } cout << ans << endl; }