제출 #302241

#제출 시각아이디문제언어결과실행 시간메모리
302241MasterTasterDetecting Molecules (IOI16_molecules)C++14
69 / 100
54 ms5096 KiB
#include "molecules.h"
#include <bits/stdc++.h>

#define ll long long
#define xx first
#define yy second

using namespace std;

ll pref[200010];

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    vector< pair<int, int> > ww; for (int i=0; i<w.size(); i++) ww.push_back({w[i], i});

    int n=w.size();
    sort(ww.begin(), ww.end());

    pref[0]=ww[0].xx;
    for (int i=1; i<n; i++)
        pref[i]=pref[i-1]+ww[i].xx;

    //cout<<"ee";
    int levo=-1, desno=-1;
    for (int i=0; i<n; i++)
    {
        int koliko=(ll)l;
        if (i) koliko+=pref[i-1];

        auto it=lower_bound(pref, pref+n, koliko);
        if (it==pref+n) continue;

        int gde=distance(pref, it);
        //cout<<gde<<" "<<pref[gde]<<" "<<koliko-l<<endl;
        if (pref[gde]-(koliko-l)>u) continue;

        //cout<<i<<endl;
        levo=i; desno=distance(pref, it);
        break;
    }

    vector<int> ret(0);
    if (levo==-1) return ret;

    for (int i=levo; i<=desno; i++) ret.push_back(ww[i].yy);
    return ret;
}

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:13:49: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     vector< pair<int, int> > ww; for (int i=0; i<w.size(); i++) ww.push_back({w[i], i});
      |                                                ~^~~~~~~~~
#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...