Submission #229790

# Submission time Handle Problem Language Result Execution time Memory
229790 2020-05-06T14:12:13 Z Tehillah Detecting Molecules (IOI16_molecules) C++14
0 / 100
5 ms 256 KB
#include "molecules.h"
#include <map>
#include <set>
using namespace std;

#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
	int n = w.size();
	multiset<int> st;
	map<int, vector<int>> pos;
	REP(i, 0, n) {
		st.insert(w[i]); 
		pos[w[i]].push_back(i);
    }
    vector<int> v;
    while(!st.empty()) {
    	auto it = st.lower_bound(l);
    	if(it == st.end()) --it;
		l -= *it;
	//	assert(!pos[*it].empty());
		v.push_back(pos[*it].back());
		pos[*it].pop_back();
		st.erase(it);
		if(l <= 0) break;
	}
	int tot = 0;
	for(int x: v) {
		tot += w[x];
	}
	if(tot < l || tot > u) {
		v.clear();
		v.push_back(-1);
	}
    return v;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Integer -1 violates the range [0, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -