Submission #819260

#TimeUsernameProblemLanguageResultExecution timeMemory
819260LeVanThucDetecting Molecules (IOI16_molecules)C++17
100 / 100
52 ms8228 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define p(x,y) pair<ll,ll>(x,y)
#define BIT(i,x) ((x>>i)&1)
#define MASK(x) (1<<x)
#define ld long double
#define __builtin_popcount __builtin_popcountll
#define pll pair<ll,ll>
template<class T1,class T2>
bool maximize(T1 &x,const T2 &y)
{
    if(x<y)
    {
        x=y;
        return 1;
    }
    return 0;
}
template<class T1,class T2>
bool minimize(T1 &x,const T2 &y)
{
    if(x>y)
    {
        x=y;
        return 1;
    }
    return 0;
}
void online()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
//#ifndef ONLINE_JUDGE
//    freopen("input.inp", "r", stdin);
//    freopen("output.out","w", stdout);
//#else
//#endif
}
const ll M=1e9,N=1e5+10;
vector<int> find_subset(int l,int r,vector<int> w)
{
    vector<pll> vt;
    for(int i=0;i<w.size();i++)
    {
        vt.emplace_back(w[i],i);
    }
    sort(vt.begin(),vt.end());
    ll sum=0;
    ll j=0;
    vector<int> res;
    res.clear();
    for(int i=0;i<w.size();i++)
    {
        sum+=vt[i].fi;
        while(sum>r&&j<i)
        {
            sum-=vt[j].fi;
            j++;
        }
        if(sum>=l&&sum<=r)
        {
            for(int k=j;k<=i;k++) res.push_back(vt[k].se);
            return res;
        }
    }
    return res;
}

Compilation message (stderr)

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