Submission #132929

#TimeUsernameProblemLanguageResultExecution timeMemory
132929wzyDetecting Molecules (IOI16_molecules)C++11
0 / 100
2 ms376 KiB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
	vector<pii> v;
	for(int i = 0 ; i < w.size() ; i ++) v.push_back({w[i] , i});
	sort(v.begin() , v.end());
	int lx = 0 ;
	int curr = 0;
	for(int i = 0 ; i < w.size(); i ++){
		curr += v[i].first;
		while(curr >= u && lx != (i)){
			curr -= v[lx].first;
			lx++;
		}	
		if(curr <= u && curr >= l){
			vector<int> p ;
			for(int j = lx ; j <= i ; j ++){
				p.push_back(v[j].second);
			}
			return p;
		}
	}
	return vector<int>();
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0 ; i < w.size() ; i ++) v.push_back({w[i] , i});
                  ~~^~~~~~~~~~
molecules.cpp:11:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  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...