Submission #748774

#TimeUsernameProblemLanguageResultExecution timeMemory
748774jamielimHiring (IOI09_hiring)C++14
60 / 100
304 ms17520 KiB
#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()){ vector<int> vec; while(!pq2.empty()){ vec.push_back(pq2.top().second); pq2.pop(); } sort(vec.begin(),vec.end()); for(int i:vec)printf("%d\n",i); break; } } }

Compilation message (stderr)

hiring.cpp: In function 'int main()':
hiring.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d%lld",&n,&w);
      |     ~~~~~^~~~~~~~~~~~~~~~
hiring.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%d%d",&s,&q);
      |         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...