Submission #488751

#TimeUsernameProblemLanguageResultExecution timeMemory
488751ala2Detecting Molecules (IOI16_molecules)C++14
69 / 100
14 ms3652 KiB
    #include "molecules.h"
    #include<bits/stdc++.h>
    using namespace std;
    vector<int> find_subset(int l, int u, vector<int> w) {
     
        pair<int,int>p[10010];
        int n=w.size();
        for(int i=0;i<n;i++)
        {
            p[i].first=w[i];
            p[i].second=i;
        }
        sort(p,p+n);
        int ll=0,rr=0;
        int sum=p[0].first;
         int bb=0;
     
        while(ll<=rr&&ll<n&&rr<n)
        {
           // <<ll<<" "<<rr<<endl;
            if(sum>u&&ll==rr)
                bb=1;
            if(sum>u)
            {
                ll++;
                sum-=p[ll-1].first;
            }
            if(sum>=l&&sum<=u)
            {
                break;
            }
            if(sum<l)
            {
                rr++;
                sum+=p[rr].first;
            }
        }
     
        vector<int>g;
        if(sum<l)
            bb=1;
        if(bb)
        {
            ll=1;
            rr=0;
        }
        for(int i=ll;i<=rr;i++)
            g.push_back(p[i].second);
            sort(g.begin(),g.end());
        return g;
    }
    //15 25
    //4 10 10 10 11

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:47:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   47 |         for(int i=ll;i<=rr;i++)
      |         ^~~
molecules.cpp:49:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   49 |             sort(g.begin(),g.end());
      |             ^~~~
#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...