Submission #112325

# Submission time Handle Problem Language Result Execution time Memory
112325 2019-05-18T18:30:46 Z ioilolcom Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long int

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
	vector<pair<int,int> > ww;
	for(int i=0; i<(int)w.size(); i++) {
		ww.push_back({w[i],i});
	}
	sort(ww.begin(),ww.end());
	vector<int> ans;
	int n=(int)w.size();
	int b=0;
	for(int a=0; a<n; a++) {
		sum+=ww[a].x;
		while(sum>u) {
			sum-=ww[b++].x;
		}
		if(cur>=l) {
			for(int k=b; k<=a; k++) {
				ans.push_back(ww[k].y);
				return ans;
			}
		}
	}

	return std::vector<int>(0);
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:18:3: error: 'sum' was not declared in this scope
   sum+=ww[a].x;
   ^~~
molecules.cpp:22:6: error: 'cur' was not declared in this scope
   if(cur>=l) {
      ^~~