제출 #488678

#제출 시각아이디문제언어결과실행 시간메모리
488678ala2Detecting Molecules (IOI16_molecules)C++14
0 / 100
0 ms332 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;
    
        bb=1;
    if(bb)
    {
        ll=1;
        rr=0;
    }
    
    for(int i=ll;i<=rr;i++)
        g.push_back(p[i].second+1);
        sort(g.begin(),g.end());
    return g;
}
//15 25
//4 10 10 10 11

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

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