제출 #415288

#제출 시각아이디문제언어결과실행 시간메모리
415288AntekbHiring (IOI09_hiring)C++14
100 / 100
921 ms34456 KiB
#include<bits/stdc++.h>
#define st first
#define nd second
using namespace std;
typedef long double ld;
int main(){
    int n;
    long long w;
    cin>>n>>w;
    vector<pair<pair<ld, int >, pair<int, int> > > V;
    for(int i=0; i<n; i++){
        int a, b;
        cin>>a>>b;
        V.push_back({{a/ld(b), a},  {b, i}});
    }
    sort(V.begin(), V.end());
    set<pair<int, int> > S;
    long long sum=0;
    int l=0;
    long double k=0;
    for(int i=0; i<n; i++){
        S.insert(V[i].nd);
        sum+=V[i].nd.st;
        /*while(S.size()&& S2.size() && *S2.begin()<*S.crbegin()){
            sum-=(*S.crbegin()).st;
            sum+=(*S.crbegin()).st;
            S.insert(*S2.begin());
            S2.erase(*S2.begin());

        }*/
        while(S.size() && sum*V[i].st.nd>w*V[i].nd.st){
            sum-=(*S.crbegin()).st;
            S.erase(S.find(*S.crbegin()));
        }
        if(S.size()>l){
            l=S.size();
            k=sum*V[i].st.nd/ld(V[i].nd.st);
        }
        else if(S.size()== l) k =min(k, sum*V[i].st.nd/ld(V[i].nd.st));
    }
    cout<<l<<"\n";
    S.clear();
    sum=0;
    for(int i=0; i<n; i++){
        S.insert(V[i].nd);
        sum+=V[i].nd.st;
        while(S.size() && sum*V[i].st.nd>w*V[i].nd.st){
            sum-=(*S.crbegin()).st;
            S.erase(S.find(*S.crbegin()));
        }
        if(S.size()==l && k==sum*V[i].st.nd/ld(V[i].nd.st)){
            for(auto j:S)cout<<j.nd+1<<"\n";
            return 0;
        }
    }
    //cout<<"a";
}

컴파일 시 표준 에러 (stderr) 메시지

hiring.cpp: In function 'int main()':
hiring.cpp:35:20: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |         if(S.size()>l){
      |            ~~~~~~~~^~
hiring.cpp:39:25: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |         else if(S.size()== l) k =min(k, sum*V[i].st.nd/ld(V[i].nd.st));
      |                 ~~~~~~~~^~~~
hiring.cpp:51:20: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |         if(S.size()==l && k==sum*V[i].st.nd/ld(V[i].nd.st)){
      |            ~~~~~~~~^~~
#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...