이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
std::vector<int> find_subset(int st, int dr, std::vector<int> w) {
int n=w.size(),ok,i;
long long sum;
vector <int> bonjour;
pair <int,int> salut[200005];
for (i=0;i<n;i++)
{
salut[i].first=w[i];
salut[i].second=i;
}
sort (salut,salut+n);
for (int i=0;i<n;i++)
{
if (w[i]>dr)
{
ok=1;
}
if (st<=w[i]&&w[i]<=dr)
{
bonjour.push_back(i);
return bonjour;
}
}
if (ok==1)
{
return bonjour;
}
sum=0;
queue <int > q;
for (i=0;i<n;i++)
{
q.push(salut[i].second);
sum=sum+salut[i].first;
while (!q.empty()&&sum>dr)
{
sum=sum-w[q.front()];
q.pop();
}
if (st<=sum&&sum<=dr)
{
while (!q.empty())
{
bonjour.push_back(q.front());
q.pop();
}
return bonjour;
}
}
return bonjour;
}
#ifdef HOME
int u,v,i,n;
int main()
{
ifstream cin("date.in");
ofstream cout("date.out");
cin>>u>>v>>n;
vector<int> a;
for (i=1;i<=n;i++)
{
int x;
cin>>x;
a.push_back(x);
}
vector <int> ceau = find_subset(u,v,a);
if (ceau.size()==0)
{
cout<<"NU EXISTA";
}
else
{
for (int i=0;i<ceau.size();i++)
{
cout<<ceau[i]<<" ";
}
}
return 0;
}
#endif // HOME
# | 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... |