Submission #223726

#TimeUsernameProblemLanguageResultExecution timeMemory
223726bharat2002Detecting Molecules (IOI16_molecules)C++14
9 / 100
5 ms384 KiB
#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
const int N=2e5 + 100;
const int mod=1e9 + 7;
#define pii pair<int, int>
#define mp make_pair
#define f first
#define s second
int n;vector< pii > vals;
bool sf(pii a, pii b);
vector<int> find_subset(int l, int u, vector<int> w)
{
	vector<int> ans;
	n=w.size();
	for(int i=0;i<w.size();i++)
	{
		vals.push_back(mp(w[i], i));
	}
	sort(vals.begin(), vals.end(), sf);
	int mval=vals.back().f;
	for(auto &i:vals) i.f-=mval;
	if(mval>u) return ans;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		sum+=vals[i-1].f;
		if(i*mval + sum>u)
		{
			if(i*mval + sum - vals[0].f<=u)
			{
				for(int j=1;j<i;j++) ans.push_back(vals[j].s);
				ans.push_back(vals.back().s);break;
			}
		}
		else if(i*mval+sum>=l)
		{
			for(int j=0;j<i;j++) ans.push_back(vals[j].s);break;
		}
	}
	return ans;
}
bool sf(pii a, pii b)
{
	return a.f>b.f;
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:16:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<w.size();i++)
              ~^~~~~~~~~
molecules.cpp:38:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    for(int j=0;j<i;j++) ans.push_back(vals[j].s);break;
    ^~~
molecules.cpp:38:50: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
    for(int j=0;j<i;j++) ans.push_back(vals[j].s);break;
                                                  ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...