#include using namespace std; using ll = long long; struct fraction{ ll p, q; fraction(ll P=0, ll Q=1) : p(P), q(Q) { if (Q < 0){ p *= -1; q *= -1; } } bool operator < (const fraction & other) const{ if (p < 0) return -p*other.q > -other.p*q; return p*other.q < other.p*q; } bool operator == (const fraction & other) const{ return p*other.q == other.p*q; } bool operator > (const fraction & other) const{ if (p < 0) return -p*other.q < -other.p*q; return p*other.q > other.p*q; } }; int main(){ ll N, M, x; fraction p; cin >> N >> M; vector A(N), B(M+1), cnt(N); for (int i=0; i> A[i]; for (int i=0; i> B[i]; priority_queue> que; for (int i=0; i