Submission #569499

#TimeUsernameProblemLanguageResultExecution timeMemory
569499penguin133Detecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms340 KiB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
int P[200005];
vector<pair<int, int> > v;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
	for(int i=0;i<w.size();i++){
		v.push_back({w[i], i});
	}
	sort(v.begin(), v.end());
    for(int i=0;i<w.size();i++){
    	P[i+1] = P[i] + v[i].first;
	}
	for(int i=0;i<w.size();i++){
		int s = i, e = v.size() - 1, ans = s-1;
		while(s <= e){
			int m = (s + e)/2;
			if(P[m+1] - P[i] > u)e = m - 1;
			else  ans = m, s = m + 1;
		}
		if(P[ans+1] - P[i] >= l && P[ans+1] - P[i] <= u){
			vector<int>ans1;
			for(int j=i;j<=ans;j++)ans1.push_back(v[j].second);
			return ans1;
		}
	}
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |  for(int i=0;i<w.size();i++){
      |              ~^~~~~~~~~
molecules.cpp:11:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i=0;i<w.size();i++){
      |                 ~^~~~~~~~~
molecules.cpp:14:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for(int i=0;i<w.size();i++){
      |              ~^~~~~~~~~
molecules.cpp:27:1: warning: control reaches end of non-void function [-Wreturn-type]
   27 | }
      | ^
#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...