Submission #715368

# Submission time Handle Problem Language Result Execution time Memory
715368 2023-03-26T14:53:34 Z Ahmed57 Hiring (IOI09_hiring) C++14
0 / 100
738 ms 31248 KB
#include <bits/stdc++.h>

using namespace std;

signed main(){
    long long n;
    long long w;
    cin>>n>>w;
    vector<pair<double,pair<double,long long>>> v;
    for(int i = 0;i<n;i++){
        double s,q;cin>>s>>q;
        v.push_back({s/q,{q,i+1}});
    }
    sort(v.begin(),v.end());
    priority_queue<pair<double,int>> q,p;
    long double sum = 0;
    long long ma = -1,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});
        while(p.size()){
        sum+=(-p.top().first);
        q.push({-p.top().first,p.top().second});
        p.pop();
        long double no =sum*v[i].first;
        bool bb = 0;
        while(no>w){
            pair<double,int>pa = q.top();
            q.pop();
            sum-=pa.first;
            p.push({-pa.first,pa.second});
            no =sum*v[i].first;
            bb = 1;
        }
        if(bb)break;
        }
        if(q.size()>ma){
            ma=q.size();
            ind = i;
            su = sum;
        }if(q.size()==ma&&su>(sum*v[i].first)){
            su = (sum*v[i].first);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});
        while(p.size()){
        sum+=(-p.top().first);
        q.push({-p.top().first,p.top().second});
        p.pop();
        long double no =sum*v[i].first;
        bool bb = 0;
        while(no>w){
            pair<double,int>pa = q.top();
            q.pop();
            sum-=pa.first;
            p.push({-pa.first,pa.second});
            no =sum*v[i].first;
            bb = 1;
        }
        if(bb)break;
        }
    }
    cout<<q.size()<<endl;
    while(q.size()){
        cout<<q.top().second<<"\n";
        q.pop();
    }
}

Compilation message

hiring.cpp: In function 'int main()':
hiring.cpp:19:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, std::pair<double, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i = 0;i<v.size();i++){
      |                   ~^~~~~~~~~
hiring.cpp:37:20: warning: comparison of integer expressions of different signedness: 'std::priority_queue<std::pair<double, int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   37 |         if(q.size()>ma){
      |            ~~~~~~~~^~~
hiring.cpp:41:21: warning: comparison of integer expressions of different signedness: 'std::priority_queue<std::pair<double, int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   41 |         }if(q.size()==ma&&su>(sum*v[i].first)){
      |             ~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Incorrect 2 ms 340 KB Output isn't correct
7 Incorrect 3 ms 340 KB Output isn't correct
8 Incorrect 5 ms 468 KB Output isn't correct
9 Incorrect 6 ms 596 KB Output isn't correct
10 Incorrect 7 ms 660 KB Output isn't correct
11 Incorrect 8 ms 664 KB Output isn't correct
12 Incorrect 10 ms 660 KB Output isn't correct
13 Incorrect 11 ms 848 KB Output isn't correct
14 Incorrect 17 ms 1064 KB Output isn't correct
15 Incorrect 21 ms 1284 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Incorrect 28 ms 1652 KB Output isn't correct
5 Incorrect 91 ms 3960 KB Output isn't correct
6 Incorrect 439 ms 21728 KB Output isn't correct
7 Incorrect 559 ms 26460 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 156 ms 7896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 331 ms 14288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 675 ms 30616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 738 ms 31248 KB Output isn't correct
2 Halted 0 ms 0 KB -