Submission #260379

# Submission time Handle Problem Language Result Execution time Memory
260379 2020-08-10T07:54:12 Z Bill_00 Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,c,d) for(ll i=c;i<=d;i++)
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
//int h[200001],p[200001];
//int sum[100001];
//pair<ll,ll>p[100001];
//pair<ll,ll>p1[100001];
//string s;
string str(string x,int l,int r){
	string h;
	for(int i=l;i<=r;i++){
		h+=x[i];
	}
	return h;
}
ll a[200001];
pair<int,int>p[200001];
int main(){
	//int color[200001];
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,l,u;
	cin >> n >> l >> u;
	for(int i=1;i<=n;i++){
		cin >> a[i];
		p[i]=mp(a[i],i);
	} 
	sort(p+1,p+n+1);
	ll sum=0,id=0;
	for(int i=1;i<=n;i++){
		sum+=p[i].ff;
		if(sum>=l && sum<=u){
			for(int j=1;j<=i;j++){
				cout << p[i].ss << ' ';
			}
			return 0;
		}
		if(sum>=l){
			sum-=p[i].ff;
			id=i-1;
			break;
		}
	}
	//cout << id << endl;
	if(id==0){
		cout << 0;
		return 0;
	}
	for(int i=id;i>=1;i--){
		sum=sum-p[i].ff;
		sum=sum+p[i+n-id].ff;
		//cout << sum << endl;
		if(sum>=l){
			for(int j=1;j<i;j++){
				cout << p[j].ss << ' ';
			}
			for(int j=i+n-id;j<=n;j++){
				cout << p[j].ss << ' ';
			}
			return 0;
		}
	}
	cout << 0;
}	

Compilation message

/tmp/ccCnqcKl.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccTl9IwD.o:molecules.cpp:(.text.startup+0x0): first defined here
/tmp/ccCnqcKl.o: In function `main':
grader.cpp:(.text.startup+0x152): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status