Submission #241175

# Submission time Handle Problem Language Result Execution time Memory
241175 2020-06-23T07:58:17 Z crossing0ver Detecting Molecules (IOI16_molecules) C++17
9 / 100
5 ms 512 KB
#include<bits/stdc++.h>
#include "molecules.h"
using namespace std;
vector<int> answer(deque<int> v) {
	vector<int> ans;
	ans.clear();
	for (int i = 0; i < v.size(); i++) {
		ans.push_back(v[i]);
	}
	return ans;
}
vector<int> find_subset(int l, int u, vector<int> w1) {
	int n = w1.size();
	vector<pair<int,int> > w;
	for (int i = 0; i < w1.size(); i++) w.push_back({w1[i],i});
	sort(w.begin(),w.end());
	long long tot = 0;
	deque<int> v;
	vector<int> ans;
	if (w[0].first > u) return ans;
	for (int i = 0; i < n; i++) {
		if ( tot + w[i].first <= l) {
			tot+=w[i].first;
			v.push_back(w[i].second); 
		}	
	}
	if (tot >= u && tot <= l) return answer(v);
	for (int i = n - 1; i >= 0; i--) {
		if (w[i].first > u) n--;
	}
	int in = (v.size() > 0 ? v.back() : -1);
	for (int i = in + 1; i < n; i++) {
		if ( tot + w[i].first >= l &&  tot + w[i].first <= u) {
			v.push_back(w[i].second);
			return answer(v);
		}
		if (tot + w[i].first > u) {
			tot -= w[v.front()].first;
			v.pop_front();
		}
		tot += w[i].first;
			v.push_back(w[i].second);
		if (tot >= l && tot <= u) return answer(v);
	}
	return ans;
}


        

Compilation message

molecules.cpp: In function 'std::vector<int> answer(std::deque<int>)':
molecules.cpp:7:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < v.size(); i++) {
                  ~~^~~~~~~~~~
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:15:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < w1.size(); i++) w.push_back({w1[i],i});
                  ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 4 ms 256 KB OK (n = 1, answer = NO)
3 Correct 5 ms 512 KB OK (n = 1, answer = YES)
4 Correct 5 ms 384 KB OK (n = 2, answer = YES)
5 Correct 4 ms 256 KB OK (n = 2, answer = YES)
6 Correct 4 ms 256 KB OK (n = 3, answer = YES)
7 Correct 5 ms 384 KB OK (n = 3, answer = YES)
8 Correct 4 ms 256 KB OK (n = 3, answer = YES)
9 Correct 5 ms 384 KB OK (n = 3, answer = YES)
10 Correct 5 ms 384 KB OK (n = 3, answer = YES)
11 Correct 4 ms 256 KB OK (n = 3, answer = YES)
12 Correct 5 ms 256 KB OK (n = 3, answer = YES)
13 Correct 5 ms 384 KB OK (n = 3, answer = NO)
14 Correct 4 ms 384 KB OK (n = 3, answer = YES)
15 Correct 5 ms 384 KB OK (n = 3, answer = YES)
16 Correct 5 ms 384 KB OK (n = 3, answer = NO)
17 Correct 5 ms 384 KB OK (n = 3, answer = NO)
18 Correct 5 ms 256 KB OK (n = 100, answer = NO)
19 Correct 5 ms 256 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB OK (n = 12, answer = YES)
2 Correct 5 ms 384 KB OK (n = 12, answer = YES)
3 Correct 4 ms 256 KB OK (n = 12, answer = NO)
4 Correct 4 ms 256 KB OK (n = 12, answer = NO)
5 Correct 5 ms 256 KB OK (n = 12, answer = YES)
6 Correct 5 ms 256 KB OK (n = 12, answer = YES)
7 Correct 5 ms 256 KB OK (n = 12, answer = YES)
8 Correct 4 ms 256 KB OK (n = 12, answer = YES)
9 Incorrect 4 ms 256 KB Contestant can not find answer, jury can
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 4 ms 256 KB OK (n = 1, answer = NO)
3 Correct 5 ms 512 KB OK (n = 1, answer = YES)
4 Correct 5 ms 384 KB OK (n = 2, answer = YES)
5 Correct 4 ms 256 KB OK (n = 2, answer = YES)
6 Correct 4 ms 256 KB OK (n = 3, answer = YES)
7 Correct 5 ms 384 KB OK (n = 3, answer = YES)
8 Correct 4 ms 256 KB OK (n = 3, answer = YES)
9 Correct 5 ms 384 KB OK (n = 3, answer = YES)
10 Correct 5 ms 384 KB OK (n = 3, answer = YES)
11 Correct 4 ms 256 KB OK (n = 3, answer = YES)
12 Correct 5 ms 256 KB OK (n = 3, answer = YES)
13 Correct 5 ms 384 KB OK (n = 3, answer = NO)
14 Correct 4 ms 384 KB OK (n = 3, answer = YES)
15 Correct 5 ms 384 KB OK (n = 3, answer = YES)
16 Correct 5 ms 384 KB OK (n = 3, answer = NO)
17 Correct 5 ms 384 KB OK (n = 3, answer = NO)
18 Correct 5 ms 256 KB OK (n = 100, answer = NO)
19 Correct 5 ms 256 KB OK (n = 100, answer = YES)
20 Correct 4 ms 256 KB OK (n = 12, answer = YES)
21 Correct 5 ms 384 KB OK (n = 12, answer = YES)
22 Correct 4 ms 256 KB OK (n = 12, answer = NO)
23 Correct 4 ms 256 KB OK (n = 12, answer = NO)
24 Correct 5 ms 256 KB OK (n = 12, answer = YES)
25 Correct 5 ms 256 KB OK (n = 12, answer = YES)
26 Correct 5 ms 256 KB OK (n = 12, answer = YES)
27 Correct 4 ms 256 KB OK (n = 12, answer = YES)
28 Incorrect 4 ms 256 KB Contestant can not find answer, jury can
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 4 ms 256 KB OK (n = 1, answer = NO)
3 Correct 5 ms 512 KB OK (n = 1, answer = YES)
4 Correct 5 ms 384 KB OK (n = 2, answer = YES)
5 Correct 4 ms 256 KB OK (n = 2, answer = YES)
6 Correct 4 ms 256 KB OK (n = 3, answer = YES)
7 Correct 5 ms 384 KB OK (n = 3, answer = YES)
8 Correct 4 ms 256 KB OK (n = 3, answer = YES)
9 Correct 5 ms 384 KB OK (n = 3, answer = YES)
10 Correct 5 ms 384 KB OK (n = 3, answer = YES)
11 Correct 4 ms 256 KB OK (n = 3, answer = YES)
12 Correct 5 ms 256 KB OK (n = 3, answer = YES)
13 Correct 5 ms 384 KB OK (n = 3, answer = NO)
14 Correct 4 ms 384 KB OK (n = 3, answer = YES)
15 Correct 5 ms 384 KB OK (n = 3, answer = YES)
16 Correct 5 ms 384 KB OK (n = 3, answer = NO)
17 Correct 5 ms 384 KB OK (n = 3, answer = NO)
18 Correct 5 ms 256 KB OK (n = 100, answer = NO)
19 Correct 5 ms 256 KB OK (n = 100, answer = YES)
20 Correct 4 ms 256 KB OK (n = 12, answer = YES)
21 Correct 5 ms 384 KB OK (n = 12, answer = YES)
22 Correct 4 ms 256 KB OK (n = 12, answer = NO)
23 Correct 4 ms 256 KB OK (n = 12, answer = NO)
24 Correct 5 ms 256 KB OK (n = 12, answer = YES)
25 Correct 5 ms 256 KB OK (n = 12, answer = YES)
26 Correct 5 ms 256 KB OK (n = 12, answer = YES)
27 Correct 4 ms 256 KB OK (n = 12, answer = YES)
28 Incorrect 4 ms 256 KB Contestant can not find answer, jury can
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 4 ms 256 KB OK (n = 1, answer = NO)
3 Correct 5 ms 512 KB OK (n = 1, answer = YES)
4 Correct 5 ms 384 KB OK (n = 2, answer = YES)
5 Correct 4 ms 256 KB OK (n = 2, answer = YES)
6 Correct 4 ms 256 KB OK (n = 3, answer = YES)
7 Correct 5 ms 384 KB OK (n = 3, answer = YES)
8 Correct 4 ms 256 KB OK (n = 3, answer = YES)
9 Correct 5 ms 384 KB OK (n = 3, answer = YES)
10 Correct 5 ms 384 KB OK (n = 3, answer = YES)
11 Correct 4 ms 256 KB OK (n = 3, answer = YES)
12 Correct 5 ms 256 KB OK (n = 3, answer = YES)
13 Correct 5 ms 384 KB OK (n = 3, answer = NO)
14 Correct 4 ms 384 KB OK (n = 3, answer = YES)
15 Correct 5 ms 384 KB OK (n = 3, answer = YES)
16 Correct 5 ms 384 KB OK (n = 3, answer = NO)
17 Correct 5 ms 384 KB OK (n = 3, answer = NO)
18 Correct 5 ms 256 KB OK (n = 100, answer = NO)
19 Correct 5 ms 256 KB OK (n = 100, answer = YES)
20 Correct 4 ms 256 KB OK (n = 12, answer = YES)
21 Correct 5 ms 384 KB OK (n = 12, answer = YES)
22 Correct 4 ms 256 KB OK (n = 12, answer = NO)
23 Correct 4 ms 256 KB OK (n = 12, answer = NO)
24 Correct 5 ms 256 KB OK (n = 12, answer = YES)
25 Correct 5 ms 256 KB OK (n = 12, answer = YES)
26 Correct 5 ms 256 KB OK (n = 12, answer = YES)
27 Correct 4 ms 256 KB OK (n = 12, answer = YES)
28 Incorrect 4 ms 256 KB Contestant can not find answer, jury can
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 4 ms 256 KB OK (n = 1, answer = NO)
3 Correct 5 ms 512 KB OK (n = 1, answer = YES)
4 Correct 5 ms 384 KB OK (n = 2, answer = YES)
5 Correct 4 ms 256 KB OK (n = 2, answer = YES)
6 Correct 4 ms 256 KB OK (n = 3, answer = YES)
7 Correct 5 ms 384 KB OK (n = 3, answer = YES)
8 Correct 4 ms 256 KB OK (n = 3, answer = YES)
9 Correct 5 ms 384 KB OK (n = 3, answer = YES)
10 Correct 5 ms 384 KB OK (n = 3, answer = YES)
11 Correct 4 ms 256 KB OK (n = 3, answer = YES)
12 Correct 5 ms 256 KB OK (n = 3, answer = YES)
13 Correct 5 ms 384 KB OK (n = 3, answer = NO)
14 Correct 4 ms 384 KB OK (n = 3, answer = YES)
15 Correct 5 ms 384 KB OK (n = 3, answer = YES)
16 Correct 5 ms 384 KB OK (n = 3, answer = NO)
17 Correct 5 ms 384 KB OK (n = 3, answer = NO)
18 Correct 5 ms 256 KB OK (n = 100, answer = NO)
19 Correct 5 ms 256 KB OK (n = 100, answer = YES)
20 Correct 4 ms 256 KB OK (n = 12, answer = YES)
21 Correct 5 ms 384 KB OK (n = 12, answer = YES)
22 Correct 4 ms 256 KB OK (n = 12, answer = NO)
23 Correct 4 ms 256 KB OK (n = 12, answer = NO)
24 Correct 5 ms 256 KB OK (n = 12, answer = YES)
25 Correct 5 ms 256 KB OK (n = 12, answer = YES)
26 Correct 5 ms 256 KB OK (n = 12, answer = YES)
27 Correct 4 ms 256 KB OK (n = 12, answer = YES)
28 Incorrect 4 ms 256 KB Contestant can not find answer, jury can
29 Halted 0 ms 0 KB -