Submission #113225

# Submission time Handle Problem Language Result Execution time Memory
113225 2019-05-24T11:28:46 Z dolphingarlic Detecting Molecules (IOI16_molecules) C++14
0 / 100
3 ms 384 KB
#include <bits/stdc++.h>
#include "molecules.h"
#define FOR(i, x, y) for (int i = x; i < y; i++)
using namespace std;

pair<int, int> a[200001];
int pref[200001];

vector<int> find_subset(int l, int u, vector<int> w) {
	int n = w.size();
	FOR(i, 0, n) {
		a[i].first = w[i];
		a[i].second = i;
	}
	sort(a, a + n);
	FOR(i, 0, n) pref[i + 1] = pref[i] + a[i].first;

	vector<int> res;
	int x = 1, y = n;
	while (x <= y) {
		int mid = (x + y) / 2;
		bool too_big = false;
		FOR(i, 0, n - mid) {
			int sum = pref[i + mid] - pref[i];
			if (sum >= l && sum <= u) {
				FOR(j, i, i + mid) res.push_back(a[j].second);
				return res;
			} else if (sum > u) {
				too_big = true;
				break;
			}
		}
		if (too_big) y = mid - 1;
		else x = mid + 1;
	}

	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB OK (n = 1, answer = NO)
2 Correct 3 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB OK (n = 12, answer = YES)
2 Correct 2 ms 384 KB OK (n = 12, answer = YES)
3 Correct 2 ms 384 KB OK (n = 12, answer = NO)
4 Correct 2 ms 384 KB OK (n = 12, answer = NO)
5 Correct 2 ms 384 KB OK (n = 12, answer = YES)
6 Incorrect 3 ms 384 KB Contestant can not find answer, jury can
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB OK (n = 1, answer = NO)
2 Correct 3 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB OK (n = 1, answer = NO)
2 Correct 3 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB OK (n = 1, answer = NO)
2 Correct 3 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB OK (n = 1, answer = NO)
2 Correct 3 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -