Submission #487652

#TimeUsernameProblemLanguageResultExecution timeMemory
487652stefantagaDetecting Molecules (IOI16_molecules)C++14
100 / 100
60 ms5556 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); 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

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:5:20: warning: unused variable 'ok' [-Wunused-variable]
    5 |     int n=w.size(),ok,i;
      |                    ^~
#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...