Submission #299125

# Submission time Handle Problem Language Result Execution time Memory
299125 2020-09-14T13:51:19 Z azatega Detecting Molecules (IOI16_molecules) C++11
0 / 100
0 ms 288 KB
#include "molecules.h"
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long

vector<int> find_subset(int l, int u, vector<int> w) {
	vector<pair<ll, int>> new_w;

	ll tot_sum = 0;
	for(int i = 0; i < w.size(); i++){
		tot_sum += w[i];
		new_w.push_back({w[i], i});
	}

	sort(new_w.begin(), new_w.end());

    ll currsum = 0;
    int tot_sum_idx = 0;

    for(int i = 0; i < new_w.size(); i++){
    	currsum += new_w[i].first;
    	while(tot_sum_idx <= i || (tot_sum_idx < new_w.size() && tot_sum+currsum > u)){
    		tot_sum -= new_w[tot_sum_idx].second;
    		tot_sum_idx++;
    	}

    	if(tot_sum + currsum >= l && tot_sum + currsum <= u){
    		vector<int> res;
			for(int x = 0; x <= i; x++)
				res.push_back(new_w[x].second);
			for(int x = tot_sum_idx; x < new_w.size(); x++)
				res.push_back(new_w[x].second);
			
			return res;
    	}
    }

    vector<int> bl;
    return bl;
}

/*int main(){
	int n, l, u;
	vector<int> niz;
	cin >> n >> l >> u;
	
	niz.resize(n);
	for(int i = 0; i < n; i++)
		cin >> niz[i];
	vector<int> rs = find_subset(l, u, niz);
	for(int i = 0; i < rs.size(); i++)
		cout << rs[i] << endl;
}*/

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:13:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for(int i = 0; i < w.size(); i++){
      |                 ~~^~~~~~~~~~
molecules.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i = 0; i < new_w.size(); i++){
      |                    ~~^~~~~~~~~~~~~~
molecules.cpp:25:45: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |      while(tot_sum_idx <= i || (tot_sum_idx < new_w.size() && tot_sum+currsum > u)){
      |                                 ~~~~~~~~~~~~^~~~~~~~~~~~~~
molecules.cpp:34:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |    for(int x = tot_sum_idx; x < new_w.size(); x++)
      |                             ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 288 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 288 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 288 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 288 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 288 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -