Submission #443852

#TimeUsernameProblemLanguageResultExecution timeMemory
443852fuad27Detecting Molecules (IOI16_molecules)C++14
69 / 100
53 ms4068 KiB
#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
	vector<pair<int, int>> k;
	for(int i = 0;i<w.size();i++) {
		k.push_back({w[i], i});
	}
	sort(k.begin(), k.end());
	int p1 = 0, p2 = 0, sum = k[0].first;
	while(p1 <w.size() and p2<w.size()) {
		if(sum < l) {
			p2++;
			sum += k[p2].first;
		}
		else if(sum > u) {
			p1++;
			sum -= k[p1-1].first;
		}
		else if(sum >= l and sum<=u) {
			vector<int> d;
			for(int i = p1;i<=p2;i++)d.push_back(k[i].second);
			return d;
		}
	}
	return {};
}

Compilation message (stderr)

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