Submission #715366

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

using namespace std;

signed main(){
    long long n;
    long long w;
    cin>>n>>w;
    vector<pair<long double,pair<long double,long long>>> v;
    for(int i = 0;i<n;i++){
        long double s,q;cin>>s>>q;
        v.push_back({s/q,{q,i+1}});
    }
    sort(v.begin(),v.end());
    priority_queue<pair<long double,int>> q,p;
    long double sum = 0;
    long long ma = 0,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(1){
        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<long 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(1){
        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<long 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<long double, std::pair<long 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<long 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<long 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 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Runtime error 1 ms 468 KB Execution killed with signal 6
3 Runtime error 1 ms 468 KB Execution killed with signal 11
4 Runtime error 75 ms 65536 KB Execution killed with signal 9
5 Runtime error 1 ms 468 KB Execution killed with signal 11
6 Runtime error 3 ms 1552 KB Execution killed with signal 11
7 Runtime error 3 ms 980 KB Execution killed with signal 6
8 Runtime error 5 ms 2056 KB Execution killed with signal 11
9 Runtime error 46 ms 33772 KB Execution killed with signal 11
10 Runtime error 90 ms 65396 KB Execution killed with signal 11
11 Runtime error 10 ms 1616 KB Execution killed with signal 11
12 Runtime error 10 ms 2116 KB Execution killed with signal 11
13 Runtime error 37 ms 21552 KB Execution killed with signal 11
14 Runtime error 84 ms 65536 KB Execution killed with signal 9
15 Runtime error 90 ms 65536 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Runtime error 1 ms 468 KB Execution killed with signal 6
3 Runtime error 1 ms 468 KB Execution killed with signal 6
4 Runtime error 92 ms 65536 KB Execution killed with signal 9
5 Runtime error 78 ms 19288 KB Execution killed with signal 11
6 Runtime error 366 ms 65536 KB Execution killed with signal 9
7 Runtime error 448 ms 65536 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Runtime error 23 ms 16176 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 2760 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 6168 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 182 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 288 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 540 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 606 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -