Submission #61091

# Submission time Handle Problem Language Result Execution time Memory
61091 2018-07-25T07:56:28 Z Tenuun Detecting Molecules (IOI16_molecules) C++17
9 / 100
4 ms 672 KB
#include "molecules.h"
#include<bits/stdc++.h>

using namespace std;

vector<int> find_subset(int l, int u, std::vector<int> w) {
	deque<int>res;
	vector<int>ans;
	vector<pair<int, int> >v;
	for(int i=0; i<w.size(); i++){
		v.push_back({w[i], i});
	}
	sort(v.rbegin(), v.rend());
	long long curr=0;
	int L=0, r=0;
	while(L<v.size()){
		r=max(r, L);
		if(L==r){
			curr=v[L].first;
			res.clear();
			res.push_back(v[L].second);
		}
		while(r+1<v.size() && curr<l){
			curr+=v[r+1].first;
			res.push_back(v[r+1].second);
			r++;
		}
		if(curr>=l && curr<=u){
			while(!res.empty()){
				ans.push_back(res.front());
				res.pop_front();
			}
			return ans;
		}
		while(!res.empty() && curr>u){
			curr-=v[L].first;
			res.pop_front();
			L++;
		}
		if(curr>=l && curr<=u){
			while(!res.empty()){
				ans.push_back(res.front());
				res.pop_front();
			}
			return ans;
		}
		L++;
	}
	if(curr>=l && curr<=u){
		while(!res.empty()){
			ans.push_back(res.front());
			res.pop_front();
		}
		return ans;
	}
	else return ans;
}

Compilation message

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