Submission #404941

#TimeUsernameProblemLanguageResultExecution timeMemory
404941ahmeterenDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w)
{
	int n = w.size();
	vector<pair<int, int> > vec(n);
	vector<long long> pre(n+1), cevap;	
	for(int i = 0; i < n; i++)
	{
		vec[i] = {w[i], i};
	}
	sort(vec.begin(), vec.end());
	for(int i = 0; i < n; i++)
		pre[i+1] = pre[i] + vec[i].first;
	for(int i = 1; i <= n; i++)
	{
		int low = 0, high = n - i + 1;
		while(low < high)
		{
			int mid = (low + high) / 2;
			long long sum = pre[mid + i] - pre[mid];
			if(sum < l)
				low = mid + 1;
			else if(sum > u)
				high = mid;
			else
			{
				for(int j = mid; j < mid + i; j++)
					cevap.push_back(vec[j].second);
				break;
			}
		}
		if(!cevap.empty())
			break;
	}
	return cevap;
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:37:9: error: could not convert 'cevap' from 'vector<long long int>' to 'vector<int>'
   37 |  return cevap;
      |         ^~~~~
      |         |
      |         vector<long long int>