Submission #537178

#TimeUsernameProblemLanguageResultExecution timeMemory
537178andrei_boacaDetecting Molecules (IOI16_molecules)C++17
69 / 100
1080 ms5696 KiB
#include <bits/stdc++.h>
#include "molecules.h"
//#include "grader.cpp"
using namespace std;
typedef long long ll;
int n;
struct date
{
    ll val,poz;
} v[200005];
bool comp(date a, date b)
{
    return a.val<b.val;
}
vector<int> find_subset(int l,int u,vector<int> w)
{
    n=w.size();
    for(int i=0;i<w.size();i++)
        if(w[i]>=l&&w[i]<=u)
            return {i};
    for(int i=0;i<w.size();i++)
        v[i+1]={w[i],i};
    sort(v+1,v+n+1,comp);
    for(int i=1;i<=n;i++)
    {
        ll suma=0;
        ll dr=0;
        for(int j=i;j<=n;j++)
        {
            suma+=v[j].val;
            if(suma>=l)
            {
                dr=j;
                break;
            }
        }
        if(suma<=u)
        {
            vector<int> vals;
            for(int j=i;j<=dr;j++)
                vals.push_back(v[j].poz);
            return vals;
        }
        for(int j=i;j<=n;j++)
            if(suma-v[j].val>=l&&suma-v[j].val<=u)
            {
                vector<int> vals;
                for(int k=i;k<=dr;k++)
                    if(k!=j)
                        vals.push_back(v[k].poz);
                return vals;
            }
    }
    return {};
}

Compilation message (stderr)

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