Submission #167873

# Submission time Handle Problem Language Result Execution time Memory
167873 2019-12-10T16:50:39 Z Peacher29 Detecting Molecules (IOI16_molecules) C++14
9 / 100
2 ms 380 KB
#include "molecules.h"

#include<bits/stdc++.h>

using namespace std;

bool b[200000];

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
	vector<pair<int,int>> p(w.size());
	vector<int> er;
	int n=w.size();
	for(int i=0;i<w.size();i++){
		p[i].first=w[i];
		p[i].second=i;
	}
	sort(p.begin(),p.end());
	long long osszeg=0;
	for(int i=p.size()-1;i>=0 && osszeg < l ; i--){
		osszeg+=p[i].first;
		b[i]=1;
	}
	int p1=p.size()-1, p2=0;
	while(osszeg>u){
		while(p2<n && osszeg-p[p1].first+p[p2].first<l){
			p2++;
		}
		if(b[p2]){
			break;
		}
		if(!b[p1]){
			break;
		}
		b[p2]=1;
		b[p1]=0;
		osszeg-=p[p1].first;
		osszeg+=p[p2].first;
	}
	if(osszeg>=l && osszeg <= u){
		for(int i=0;i<n;i++){
			if(b[i])
				er.push_back(p[i].second);
		}
	}
	return er;
}

Compilation message

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