Submission #225907

# Submission time Handle Problem Language Result Execution time Memory
225907 2020-04-22T01:50:02 Z frodakcin Detecting Molecules (IOI16_molecules) C++11
0 / 100
5 ms 256 KB
#include "molecules.h"

#include <cassert>
#include <algorithm>

using ll = long long;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
	int N = w.size();
	std::vector<int> o(N);
	for(int i = 0;i < N;++i) o[i] = i;
	std::sort(o.begin(), o.end(), [&](int a, int b){return w[a]<w[b];});
	std::sort(w.begin(), w.end());
	
	std::vector<ll> vl(N, 0), vr(N, 0);
	for(int i = 0;i < N;++i)
		vl[i] = w[i] + (i ? vl[i-1] : 0LL);
	for(int i = 0;i < N;++i)
		vr[i] = w[N-i-1] + (i ? vr[i-1] : 0LL);
	for(int i = 0;i < N;++i)
		if(vl[i] <= u && l <= vr[i])
		{
			//answer
			ll s = vl[i];
			int j = i;
			for(;j >= 0 && s < l;--j) s += w[N-i-1+j] - w[j];
			std::vector<int> ans(0);
			for(int k = 0;k <= j;++k) ans.push_back(o[k]+1);
			for(int k = N-i+j;k < N;++k) ans.push_back(o[k]+1);
			return ans;
		}
	return std::vector<int>(0);
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 4 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Integer 12 violates the range [0, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 4 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 4 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 4 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 4 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -