Submission #956140

# Submission time Handle Problem Language Result Execution time Memory
956140 2024-04-01T07:33:07 Z manishjha91 Detecting Molecules (IOI16_molecules) C++17
Compilation error
0 ms 0 KB
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
	
	std::vector<pair<int,int>> curr;
	
	for(int i=0; i<w.size(); i++)
	{
		curr.push_back({w[i],i});
	}
	
	sort(curr.begin(),curr.end());
	
	long long sum = 0;
	bool found = 0;
	int low = 0;
	int hi = 0;
	for(; hi<curr.size(); hi++)
	{
		sum+=curr[hi].first;
		
		while(sum>u)
		{
			sum-=curr[low++].first;
		}
		
		if(sum>=l)
		{
			found = 1;
			break;
		}
	}
	
	if(!found)
	    return std::vector<int>(0);
	    
	std::vector<int> res;
	for(int i=low; i<=hi; i++)
	{
		res.push_back(curr[i].second);
	}
	
	sort(res.begin(),res.end());
	return res;
}

Compilation message

molecules.cpp:2:6: error: 'vector' in namespace 'std' does not name a template type
    2 | std::vector<int> find_subset(int l, int u, std::vector<int> w) {
      |      ^~~~~~
molecules.cpp:1:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
  +++ |+#include <vector>
    1 |