Submission #167870

# Submission time Handle Problem Language Result Execution time Memory
167870 2019-12-10T16:46:45 Z Peacher29 Detecting Molecules (IOI16_molecules) C++14
0 / 100
2 ms 376 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){
		if(b[p2]){
			break;
		}
		if(!b[p1]){
			break;
		}
		b[p2]=1;
		b[p1]=0;
		osszeg-=p[p1].first;
		osszeg+=p[p2].first;
	}
	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 Incorrect 2 ms 376 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB sum of weights should be in [302..304] but it is 305
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -