| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1295976 | exoworldgd | Hiring (IOI09_hiring) | C++20 | 0 ms | 0 KiB |
#pragma GCC optimize("O5,unroll-loops,inline,fast-math")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#include <bits/stdc++.h>
#define exoworldgd cin.tie(0)->sync_with_stdio(0),cout.tie(0)
#define int long long
using namespace std;
int n,w,s,q,mx=-1,sum=0;
tuple<double,int,int> a[500005];
signed main(void) {
exoworldgd;
cin >> n >> w;
for (int i = 0; i < n; i++) cin >> s >> q, a[i] = {s*1.0/q,s,q};
sort(a,a+n);
priority_queue<int> pq;
for (int i = 0; i < n; i++) {
pq.push(get<2>(a[i])),sum += get<2>(a[i]);
while (!pq.empty() && get<1>(a[i])*sum > w*get<2>(a[i])) sum -= pq.top(), pq.pop();
mx = max(mx,(int)pq.size());
}
cout << mx;
}
