#pragma GCC optimize("Ofast") #pragma GCC target("avx2,bmi2,popcnt,lzcnt") #include #include #include #include #include #include class strictInput { char *p; off_t cur = 0; off_t len = 0; public: explicit strictInput(int fd = 0) { struct stat st; fstat(fd, &st); p = (char *)mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); len = st.st_size; } char readChar() { assert(cur != len); return p[cur++]; } void unreadChar() { assert(cur != 0); --cur; } bool isEOF() { return cur == len; } void readEOF() { assert(isEOF()); } void readSpace() { assert(readChar() == ' '); } void readEoln() { assert(readChar() == '\n'); } // reads uint64_t in range [from, to] uint64_t readU64(uint64_t from = 0, uint64_t to = UINT64_MAX) { uint64_t cur = 0; off_t read_cnt = 0; bool leading_zero = false; while (!isEOF()) { char p = readChar(); if (!('0' <= p && p <= '9')) { unreadChar(); break; } uint64_t v = p - '0'; assert(cur <= UINT64_MAX / 10); cur *= 10; assert(cur <= UINT64_MAX - v); cur += v; if (read_cnt == 0 && v == 0) leading_zero = true; ++read_cnt; } if (cur == 0) assert(read_cnt == 1); else assert(!leading_zero); assert(from <= cur && cur <= to); return cur; } // reads int64_t in range [from, to] int64_t readI64(int64_t from = INT64_MIN, int64_t to = INT64_MAX) { uint64_t cur = 0; off_t read_cnt = 0; bool leading_zero = false; bool leading_minus = readChar() == '-'; if (!leading_minus) unreadChar(); while (!isEOF()) { char p = readChar(); if (!('0' <= p && p <= '9')) { unreadChar(); break; } uint64_t v = p - '0'; assert(cur <= UINT64_MAX / 10); cur *= 10; assert(cur <= UINT64_MAX - v); cur += v; if (read_cnt == 0 && v == 0) leading_zero = true; ++read_cnt; } if (cur == 0) assert(read_cnt == 1 && !leading_minus); else assert(!leading_zero); if (cur <= INT64_MAX) { int64_t ret = cur; if (leading_minus) ret = -ret; assert(from <= ret && ret <= to); return ret; } else { assert(leading_minus && cur == uint64_t(INT64_MIN)); assert(from == INT64_MIN); return INT64_MIN; } } }; #include #include #include using namespace std; int main() { strictInput inf; int N = inf.readI64(1, 100'000); inf.readSpace(); long long K = inf.readI64(1, 500'000'000'000'000'000); inf.readEoln(); vector A(N); for (int i = 0; i < N; ++i) { A[i] = inf.readI64(1, 1'000'000'000); if (i == N - 1) inf.readEoln(); else inf.readSpace(); } inf.readEOF(); sort(A.begin(), A.end()); int r = N; long long ans = 0; for (int l = 0; l < N; ++l) { while (r != 0 && (long long)A[l] * A[r - 1] >= 2 * K) --r; ans += N - r; } cout << ans << endl; }