#include <bits/stdc++.h>
using namespace std;
#define fi first.first
#define se first.second
#define id second
#define pb push_back
#define pii pair<int,int>
#define ll __int128
#define pll pair<ll,ll>
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define SZ(x) ((int)((x).size()))
const int maxn = 5e5+10;
int n;
ll m;
pair<pii,int> worker[maxn];
bool cmp(pair<pii,int> x, pair<pii,int> y) {
return x.fi*y.se < y.fi*x.se;
}
priority_queue <pii> q;
void solve() {
while (!q.empty()) q.pop();
ll tmp = 0;
int hi = -1,pos;
ll val;
rep(i,0,n) {
q.push({worker[i].se,i}),tmp += worker[i].se;
while (tmp * worker[i].fi > m*worker[i].se) tmp -= q.top().first, q.pop();
if (SZ(q) > hi or (SZ(q)==hi and val * worker[pos].fi * worker[i].se > tmp*worker[i].fi*worker[pos].se)) hi = SZ(q),pos = i,val = tmp;
}
while (!q.empty()) q.pop();
tmp = 0;
rep(i,0,pos+1) {
q.push({worker[i].se,i}),tmp += worker[i].se;
while (tmp * worker[i].fi > m*worker[i].se) tmp -= q.top().first, q.pop();
}
printf("%d\n",hi);
while (!q.empty()) printf("%d\n",worker[q.top().second].id),q.pop();
}
bool check(int cnt, bool hi) {
return false;
}
int main() {
scanf("%d %lld",&n,&m);
rep(i,0,n) {
cin>>worker[i].fi>>worker[i].se;
worker[i].id = i+1;
}
sort(worker,worker+n,cmp);
solve();
}
/*
4 100 5 1000 10 100 8 10 20 1
3 4 1 2 1 3 1 3
3 40 10 1 10 2 10 3
*/
Compilation message
hiring.cpp: In function 'int main()':
hiring.cpp:51:15: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type '__int128*' [-Wformat=]
51 | scanf("%d %lld",&n,&m);
| ~~~^ ~~
| | |
| | __int128*
| long long int*
hiring.cpp:51:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
51 | scanf("%d %lld",&n,&m);
| ~~~~~^~~~~~~~~~~~~~~~~
hiring.cpp: In function 'void solve()':
hiring.cpp:28:14: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
28 | int hi = -1,pos;
| ^~~
hiring.cpp:33:40: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]
33 | if (SZ(q) > hi or (SZ(q)==hi and val * worker[pos].fi * worker[i].se > tmp*worker[i].fi*worker[pos].se)) hi = SZ(q),pos = i,val = tmp;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
3 ms |
340 KB |
Output is correct |
9 |
Correct |
4 ms |
340 KB |
Output is correct |
10 |
Correct |
5 ms |
388 KB |
Output is correct |
11 |
Correct |
6 ms |
340 KB |
Output is correct |
12 |
Correct |
8 ms |
652 KB |
Output is correct |
13 |
Correct |
8 ms |
452 KB |
Output is correct |
14 |
Correct |
11 ms |
680 KB |
Output is correct |
15 |
Correct |
13 ms |
744 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
20 ms |
852 KB |
Output is correct |
5 |
Correct |
48 ms |
1868 KB |
Output is correct |
6 |
Correct |
294 ms |
8540 KB |
Output is correct |
7 |
Correct |
373 ms |
10500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
113 ms |
3512 KB |
Output is correct |
2 |
Correct |
117 ms |
3512 KB |
Output is correct |
3 |
Correct |
121 ms |
3408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
186 ms |
5812 KB |
Output is correct |
2 |
Correct |
164 ms |
5716 KB |
Output is correct |
3 |
Correct |
160 ms |
5828 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
433 ms |
11916 KB |
Output is correct |
2 |
Correct |
416 ms |
11936 KB |
Output is correct |
3 |
Correct |
411 ms |
11952 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
460 ms |
12984 KB |
Output is correct |
2 |
Correct |
460 ms |
12956 KB |
Output is correct |
3 |
Correct |
473 ms |
12980 KB |
Output is correct |