# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
525989 | gs21045 | Detecting Molecules (IOI16_molecules) | C++14 | 1 ms | 204 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "molecules.h"
#define endl '\n'
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
vector<int> find_subset(int l,int u,vector<int> a)
{
vector<int> result;
int n=a.size();
vector<pll> w(n+1); for(int i=1; i<=n; i++) w[i].F=(ll)a[i-1],w[i].S=i;
sort(w.begin()+1,w.end());
vector<ll> sum(n+1);
for(int i=1; i<w.size(); i++) sum[i]=sum[i-1]+w[i].F;
int st=n,en=n;
while(st>1 && sum[en]-sum[st-1]<(ll)l) st--;
if(sum[en]-sum[st-1]<(ll)l) return result;
while(en>1 && sum[en]-sum[st-1]>(ll)u)
{
en--;
while(st>1 && sum[en]-sum[st-1]<(ll)l) st--;
}
if(sum[en]-sum[st-1]<=(ll)u && sum[en]-sum[st-1]>=(ll)l)
for(int i=st; i<=en; i++)
result.push_back(w[i].S);
return result;
}
/*
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,l,u;
cin>>n>>l>>u;
vector<int> w(n);
for(int i=0; i<n; i++) cin>>w[i];
vector<int> result=find_subset(l,u,w);
cout<<(int)result.size()<<endl;
for(int i=0; i<(int)result.size(); i++) cout<<result[i]<<' ';
return 0;
}
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |