Submission #487646

#TimeUsernameProblemLanguageResultExecution timeMemory
487646stefantagaDetecting Molecules (IOI16_molecules)C++14
0 / 100
2 ms1744 KiB
#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 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...