Submission #632249

#TimeUsernameProblemLanguageResultExecution timeMemory
632249deviceDetecting Molecules (IOI16_molecules)C++17
0 / 100
0 ms212 KiB
#include "molecules.h"
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
	int n = w.size();
	vector<pair<int,int>> v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i].ff;
		v[i].ss = i;
	}
	sort(v.begin(), v.end());
	int cur = v[0].ff;
	int ptr = 0;
	if(cur >= l && cur <= u){
		vector<int> ret;
		ret.pb(v[0].ss);
		return ret;
	}
	for(int i = 1; i < n; i++){
		cur += v[i].ff;
		if(cur >= l && cur <= u){
			vector<int> ret;
			for(int j = ptr; j <= i; j++){
				ret.pb(v[j].ss);
			}
			return ret;
		}
		while(cur > u && ptr <= i){
			cur -= v[ptr].ff;
			ptr++;
		}
		if(cur >= l && cur <= u){
			vector<int> ret;
			for(int j = ptr; j <= i; j++){
				ret.pb(v[j].ss);
			}
			return ret;
		}
	}
    return std::vector<int>(0);
}
#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...