# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
715370 | Ahmed57 | Hiring (IOI09_hiring) | C++14 | 1232 ms | 63400 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;
signed main(){
long long n;
long long w;
cin>>n>>w;
vector<pair<long double,pair<long double,long long>>> v;
for(int i = 0;i<n;i++){
long double s,q;cin>>s>>q;
v.push_back({s/q,{q,i+1}});
}
sort(v.begin(),v.end());
priority_queue<pair<long double,int>> q,p;
long double sum = 0;
long long ma = 0,ind = -1;
long double su = 0.0;
for(int i = 0;i<v.size();i++){
p.push({-v[i].second.first,v[i].second.second});
sum+=(-p.top().first);
q.push({-p.top().first,p.top().second});
p.pop();
long double no =sum*v[i].first;
while(no>w){
pair<long double,int>pa = q.top();
q.pop();
sum-=pa.first;
p.push({-pa.first,pa.second});
no =sum*v[i].first;
}
if(q.size()>ma){
ma=q.size();
ind = i;
su = no;
}if(q.size()==ma&&su>no){
su = no;ind =i;
}
}
while(!q.empty())q.pop();
while(!p.empty())p.pop();
sum=0;
for(int i = 0;i<=ind;i++){
p.push({-v[i].second.first,v[i].second.second});
sum+=(-p.top().first);
q.push({-p.top().first,p.top().second});
p.pop();
long double no =sum*v[i].first;
while(no>w){
pair<long double,int>pa = q.top();
q.pop();
sum-=pa.first;
p.push({-pa.first,pa.second});
no =sum*v[i].first;
}
}
cout<<q.size()<<endl;
while(q.size()){
cout<<q.top().second<<"\n";
q.pop();
}
}
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... |