Submission #273036

#TimeUsernameProblemLanguageResultExecution timeMemory
273036ggoorooDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms384 KiB
#include "molecules.h"

#include <cstdio>
#include <iostream>
#include <algorithm>
#define F first
#define S second
#define N 200005
using namespace std;

typedef long long ll;
vector<int> ans;

ll n, v[N];
pair<ll, ll> a[N];
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
	ll i, j, s, en, r = u;
	n = w.size();
	for (i =0; i <n; i++) {
		a[i].F = w[i];
		a[i].S = i;
	}
	sort(a, a + n);
	s = 0;
	for (i =0; i< n; i++) {
		if (s + a[i].F <= r) {s += a[i].F; v[a[i].S] = 1;}
		else break;
	}
	en = i;
	for (i = 0, j = en; i < en && j < n && s < l; i++, j++) {
		s -= a[i].F;
		s += a[j].F;
		v[a[i].S] = 0;
		v[a[j].S] = 1;
	}
	for (i =0; i < n; i++) if (v[i]) ans.push_back(i);
	return ans;
}
#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...