Submission #196900

# Submission time Handle Problem Language Result Execution time Memory
196900 2020-01-17T14:55:40 Z Juney Detecting Molecules (IOI16_molecules) C++14
9 / 100
10 ms 376 KB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

vector<int> find_subset(int l, int u, vector<int> w) {
	vector<int> ans;
	vector<pii> v;
	for(int i=0; i<w.size(); i++) v.push_back(pii(w[i], i));
	sort(v.begin(), v.end(), greater<pii>());
	ll sum = 0;
	for(int i=0; i<v.size(); i++) {
		sum += v[i].first;
		ans.push_back(v[i].second);
		if(sum >= l) {
			if(sum <= u) return ans;
			int k = 0;
			for(int j=v.size()-1; j>i && k<ans.size(); j++) {
				sum -= w[ans[k]];
				sum += w[v[j].second];
				ans[k] = v[j].second;
				k++;
				if(sum <= u) return ans;
			}
			return vector<int> ();
		}
	}
	return vector<int> ();
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:11:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<w.size(); i++) v.push_back(pii(w[i], i));
               ~^~~~~~~~~
molecules.cpp:14:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<v.size(); i++) {
               ~^~~~~~~~~
molecules.cpp:20:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=v.size()-1; j>i && k<ans.size(); j++) {
                                 ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB OK (n = 1, answer = NO)
2 Correct 10 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 5 ms 356 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 0 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 256 KB OK (n = 3, answer = YES)
12 Correct 2 ms 256 KB OK (n = 3, answer = YES)
13 Correct 2 ms 256 KB OK (n = 3, answer = NO)
14 Correct 2 ms 256 KB OK (n = 3, answer = YES)
15 Correct 2 ms 256 KB OK (n = 3, answer = YES)
16 Correct 2 ms 256 KB OK (n = 3, answer = NO)
17 Correct 2 ms 252 KB OK (n = 3, answer = NO)
18 Correct 2 ms 376 KB OK (n = 100, answer = NO)
19 Correct 4 ms 376 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB item #0 is taken twice
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB OK (n = 1, answer = NO)
2 Correct 10 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 5 ms 356 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 0 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 256 KB OK (n = 3, answer = YES)
12 Correct 2 ms 256 KB OK (n = 3, answer = YES)
13 Correct 2 ms 256 KB OK (n = 3, answer = NO)
14 Correct 2 ms 256 KB OK (n = 3, answer = YES)
15 Correct 2 ms 256 KB OK (n = 3, answer = YES)
16 Correct 2 ms 256 KB OK (n = 3, answer = NO)
17 Correct 2 ms 252 KB OK (n = 3, answer = NO)
18 Correct 2 ms 376 KB OK (n = 100, answer = NO)
19 Correct 4 ms 376 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 256 KB item #0 is taken twice
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB OK (n = 1, answer = NO)
2 Correct 10 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 5 ms 356 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 0 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 256 KB OK (n = 3, answer = YES)
12 Correct 2 ms 256 KB OK (n = 3, answer = YES)
13 Correct 2 ms 256 KB OK (n = 3, answer = NO)
14 Correct 2 ms 256 KB OK (n = 3, answer = YES)
15 Correct 2 ms 256 KB OK (n = 3, answer = YES)
16 Correct 2 ms 256 KB OK (n = 3, answer = NO)
17 Correct 2 ms 252 KB OK (n = 3, answer = NO)
18 Correct 2 ms 376 KB OK (n = 100, answer = NO)
19 Correct 4 ms 376 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 256 KB item #0 is taken twice
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB OK (n = 1, answer = NO)
2 Correct 10 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 5 ms 356 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 0 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 256 KB OK (n = 3, answer = YES)
12 Correct 2 ms 256 KB OK (n = 3, answer = YES)
13 Correct 2 ms 256 KB OK (n = 3, answer = NO)
14 Correct 2 ms 256 KB OK (n = 3, answer = YES)
15 Correct 2 ms 256 KB OK (n = 3, answer = YES)
16 Correct 2 ms 256 KB OK (n = 3, answer = NO)
17 Correct 2 ms 252 KB OK (n = 3, answer = NO)
18 Correct 2 ms 376 KB OK (n = 100, answer = NO)
19 Correct 4 ms 376 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 256 KB item #0 is taken twice
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB OK (n = 1, answer = NO)
2 Correct 10 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 5 ms 356 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 0 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 256 KB OK (n = 3, answer = YES)
12 Correct 2 ms 256 KB OK (n = 3, answer = YES)
13 Correct 2 ms 256 KB OK (n = 3, answer = NO)
14 Correct 2 ms 256 KB OK (n = 3, answer = YES)
15 Correct 2 ms 256 KB OK (n = 3, answer = YES)
16 Correct 2 ms 256 KB OK (n = 3, answer = NO)
17 Correct 2 ms 252 KB OK (n = 3, answer = NO)
18 Correct 2 ms 376 KB OK (n = 100, answer = NO)
19 Correct 4 ms 376 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 256 KB item #0 is taken twice
21 Halted 0 ms 0 KB -