# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1001921 | ayankarimova | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 444 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 "molecules.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<int>ans;
map<ll, ll>mp;
map<ll, vector<ll>>mp1;
for(int i=0; i<w.size(); i++){
mp[w[i]]++;
mp1[w[i]].push_back(i);
}
//cout<<mp[6]<<endl;
for(auto i:mp){
ll num=(l+i.first-1)/i.first;
if(num<=i.second && num*i.first<=u && num*i.first>=l){
for(auto j:mp1[i.first]){
ans.push_back(j);
if(ans.size()==num) break;
}
//cout<<1<<endl;
sort(ans.begin(), ans.end());
return ans;
}
if(mp.count(i.first+1)>0 && u-l==1){
ll cur=l-i.second*i.first;
ll num1=(cur+(i.first+1)-1)/(i.first+1);
if(num1<=mp[i.first+1] && i.second*i.first+num1*(i.first+1)<=u && i.second*i.first+num1*(i.first+1)>=l){
for(auto j:mp1[i.first]){
ans.push_back(j);
if(ans.size()==i.second) break;
}
for(auto j:mp1[i.first+1]){
ans.push_back(j);
if(ans.size()==i.second+num1) break;
}
//cout<<2<<endl;
sort(ans.begin(), ans.end());
cout<<1<<endl;
return ans;
}
}
if(mp.count(i.first-1)>0 && u-l==1){
ll cur=l-i.second*i.first;
ll num1=(cur+(i.first-1)-1)/(i.first-1);
if(num1<=mp[i.first-1] && i.second*i.first+num1*(i.first-1)<=u && i.second*i.first+num1*(i.first-1)>=l){
for(auto j:mp1[i.first]){
ans.push_back(j);
if(ans.size()==i.second) break;
}
for(auto j:mp1[i.first-1]){
ans.push_back(j);
if(ans.size()==i.second+num1) break;
}
//cout<<2<<endl;
sort(ans.begin(), ans.end());
cout<<2<<endl;
return ans;
}
}
}
return ans;
}
/*
{} []
7
13 14
2 2 3 3 3 4 4
*/
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... |