제출 #748777

#제출 시각아이디문제언어결과실행 시간메모리
748777jamielimHiring (IOI09_hiring)C++14
0 / 100
288 ms14940 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; double price=w; 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()); if(ans==(int)pq.size()){ price=min(price,sum*v); } } 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()&&abs(price-sum*v)<1e-9){ while(!pq2.empty()){ printf("%d\n",pq2.top().second); pq2.pop(); } break; } } }

컴파일 시 표준 에러 (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...