이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
for(auto i:w)
mp[i]++;
for(auto i:mp){
ll num=(l+i.first-1)/i.first;
if(num<=i.second && num*i.first<=u){
for(int j=1; j<=num; j++){
ans.push_back(i.first);
}
//cout<<1<<endl;
return ans;
}
if(mp[i.first+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){
for(int j=1; j<=i.second; j++){
ans.push_back(i.first);
}
for(int j=1; j<=num1; j++){
ans.push_back(i.first+1);
}
//cout<<2<<endl;
return ans;
}
}
if(mp[i.first-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){
for(int j=1; j<=num; j++){
ans.push_back(i.first);
}
for(int j=1; j<=num1; j++){
ans.push_back(i.first-1);
}
//cout<<3<<endl;
return ans;
}
}
}
return ans;
}
/*
{} []
7
13 14
2 2 3 3 3 4 4
*/
# | 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... |