Submission #284118

#TimeUsernameProblemLanguageResultExecution timeMemory
284118IBMGDetecting Molecules (IOI16_molecules)C++14
100 / 100
61 ms6252 KiB
#include "molecules.h"
#include <bits/stdc++.h>

using namespace std;

std::vector<int> find_subset(int l, int u, std::vector<int> w)
{
    long au = 0;
    int iz = 0, de = 0;
    vector < pair < int, int > > v;
    vector < int > ans;
    for (int i = 0; i < w.size(); i ++)
    {
        v.push_back(make_pair(w[i], i));
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); i ++)
    {
        au += v[i].first;
        de = i;
        while (au > u)
        {
            au -= v[iz].first;
            iz ++;
        }
        if (au >= l && au <= u)
        {
            for (int j = iz; j <= de; j ++)
            {
                ans.push_back(v[j].second);
            }
            break;
        }
    }
    sort(ans.begin(), ans.end());
    return ans;
}

Compilation message (stderr)

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