# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
748773 | jamielim | Hiring (IOI09_hiring) | C++14 | 297 ms | 21236 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n;
long long w;
pair<pair<double,int>,int> p[500005];
int main() {
scanf("%d%lld",&n,&w);
int s,q;
for(int i=0;i<n;i++){
scanf("%d%d",&s,&q);
p[i].first=make_pair((double)s/(double)q,q);
p[i].second=i+1;
}
sort(p,p+n);
int ans=0;
priority_queue<int> pq;
long long sum=0;
for(int i=0;i<n;i++){
sum+=p[i].first.second;
pq.push(p[i].first.second);
double v=p[i].first.first;
while(!pq.empty()&&sum>w/v){
sum-=pq.top();
pq.pop();
}
ans=max(ans,(int)pq.size());
}
printf("%d\n",ans);
sum=0;
priority_queue<pair<int,int> > pq2;
for(int i=0;i<n;i++){
sum+=p[i].first.second;
pq2.push(make_pair(p[i].first.second,p[i].second));
double v=p[i].first.first;
while(!pq2.empty()&&sum>w/v){
sum-=pq2.top().first;
pq2.pop();
}
if(ans==(int)pq2.size()){
while(!pq2.empty()){
printf("%d\n",pq2.top().second);
pq2.pop();
}
break;
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |