Submission #623024

#TimeUsernameProblemLanguageResultExecution timeMemory
623024sofapudenHiring (IOI09_hiring)C++14
100 / 100
671 ms39288 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; struct T{ ll a, b, i; }; bool cmp(T a, T b){ return a.a*b.b < b.a*a.b; } void solve(){ ll n, w; cin >> n >> w; vector<T> A(n); for(int i = 0; i < n; ++i)cin >> A[i].a >> A[i].b, A[i].i = i+1; sort(A.begin(),A.end(),cmp); vector<pair<ll,ll>> v(n); for(int i = 0; i < n; ++i)v[i] = {A[i].a,A[i].b}; ll su = 0; ll cn = 0; pair<ll,ll> mn = {0,0}; multiset<ll> cur; set<pair<ll,ll>> in; for(int i = 0; i < n; ++i){ su+=v[i].second; cur.insert(v[i].second); while(su*v[i].first > w * v[i].second){ su-=*prev(cur.end()); cur.erase(prev(cur.end())); } if(cn == cur.size()){ if(mn.first*v[i].second > su*v[i].first*mn.second){ mn = {su*v[i].first,v[i].second}; } } if(cn < cur.size()){ cn = cur.size(); mn = {su*v[i].first,v[i].second}; } } cout << cn << '\n'; su = 0; for(int i = 0; i < n; ++i){ su+=v[i].second; in.insert({v[i].second,i}); while(su*v[i].first > w * v[i].second){ su-=prev(in.end())->first; in.erase(prev(in.end())); } if(in.size() == cn && mn == make_pair(su*v[i].first,v[i].second)){ for(auto x : in)cout << A[x.second].i << '\n'; return; } } } int main(){ solve(); }

Compilation message (stderr)

hiring.cpp: In function 'void solve()':
hiring.cpp:34:9: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   if(cn == cur.size()){
      |      ~~~^~~~~~~~~~~~~
hiring.cpp:39:9: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   if(cn < cur.size()){
      |      ~~~^~~~~~~~~~~~
hiring.cpp:53:16: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   53 |   if(in.size() == cn && mn == make_pair(su*v[i].first,v[i].second)){
      |      ~~~~~~~~~~^~~~~
#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...