Submission #677549

#TimeUsernameProblemLanguageResultExecution timeMemory
677549hello_there_123Detecting Molecules (IOI16_molecules)C++17
69 / 100
1086 ms4440 KiB
#include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l,int u,vector<int> w){ vector<pair<int,int> >lol; for(int i=0;i<w.size();i++){ lol.push_back(make_pair(w[i],i)); } sort(lol.begin(),lol.end()); int n = w.size(); vector<int>ans; vector<int>cur; queue<pair<int,int> >q; for(int i=1;i<=n;i++){ while(!q.empty()) q.pop(); cur.clear(); int sum = 0; for(int j=i-1;j>=0;j--){ sum+=lol[n-j-1].first; q.push(make_pair(lol[n-j-1].first,lol[n-j-1].second)); } if(sum<l) continue; for(int j=0;j<i;j++){ if(sum<=u && sum>=l){ while(!q.empty()){ ans.push_back(q.front().second); q.pop(); } return ans; } else{ sum-=q.front().first; q.pop(); sum+=lol[j].first; q.push(make_pair(lol[j].first,lol[j].second)); } } if(sum<=u && sum>=l){ while(!q.empty()){ ans.push_back(q.front().second); q.pop(); } return ans; } } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:5:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 |    for(int i=0;i<w.size();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...