# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
436833 | adamjinwei | Hiring (IOI09_hiring) | C++14 | 1587 ms | 25080 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>
#include <bits/extc++.h>
using namespace __gnu_pbds;
#define inf 1000000000000000007ULL
#define mod 1000000007
#define rnd() dist(rand_num)
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
//#define int long long
using namespace std;
unsigned seed=std::chrono::system_clock::now().time_since_epoch().count();
mt19937 rand_num(seed);
uniform_int_distribution<int> dist(0,inf);
template <typename T> void read(T &x){
x=0;char ch=getchar();int fh=1;
while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
x*=fh;
}
template <typename T> void write(T x) {
if (x<0) x=-x,putchar('-');
if (x>9) write(x/10);
putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
write(x);
puts("");
}
int n;
long long w;
pair<pair<long double,int>,int> p[500005];
signed main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
read(n);read(w);
for(register int i=1;i<=n;++i)
{
int s,q;
read(s);read(q);
p[i]=make_pair(make_pair((long double)s/(long double)q,q),i);
}
sort(p+1,p+n+1);
int ans=0;
long double mn=inf;
__gnu_pbds::priority_queue<pair<int,int>,less<pair<int,int>>,pairing_heap_tag> pq,anspq;
unsigned long long sum=0;
for(register int i=1;i<=n;++i)
{
pq.push(make_pair(p[i].first.second,i));
sum+=p[i].first.second;
while(sum*p[i].first.first>w+1e-8)
{
sum-=pq.top().first;
pq.pop();
}
if(ans<pq.size())
{
ans=pq.size();
mn=sum*p[i].first.first;
anspq=pq;
}
else if(ans==pq.size()&&sum*p[i].first.first<mn-1e-8)
{
mn=sum*p[i].first.first;
anspq=pq;
}
}
writeln(ans);
while(!anspq.empty())
{
writeln(p[anspq.top().second].second);
anspq.pop();
}
return 0;
}
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... |