Submission #319353

# Submission time Handle Problem Language Result Execution time Memory
319353 2020-11-05T01:46:09 Z mglstew Detecting Molecules (IOI16_molecules) C++17
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;

vector<int> find_subset(int l, int u, std::vector<int> w) {
	vector<pair<int, int> > x;
	for(int i = 0; i < w.size(); i++){
		x.push_back(make_pair(w[i], i));
	}
    sort(x.begin(), x.end());
    int n = x.size();
    int L = 0;
    int R = 0;
    long long sum = 0;
    vector<int> a;
    while(R < n){
    	sum += x[R].first;
    	while(sum > u && L <= R){
    		sum -= x[L].first;
    		L++;
    	}
    	if(sum >= 1){
    		for(int i = L; i <= R; i++){
    			a.push_back(w[i]);
    			break;
    		}
    	}
    	R++;
    }
    if(a.size() == 0){
    	a.push_back(0);
    }
    return a;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |  for(int i = 0; i < w.size(); i++){
      |                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Integer 9 violates the range [0, 0]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Integer 50 violates the range [0, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Integer 9 violates the range [0, 0]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Integer 9 violates the range [0, 0]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Integer 9 violates the range [0, 0]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Integer 9 violates the range [0, 0]
2 Halted 0 ms 0 KB -