Submission #423794

#TimeUsernameProblemLanguageResultExecution timeMemory
423794ApiramDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms332 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> arr) { priority_queue<pair<int64_t,int>,vector<pair<int64_t,int>>,greater<pair<int64_t,int>>>q; int64_t sum =0; for(int i =0;i<arr.size();++i){ if (sum>=l&&sum<=u)break; if (sum+arr[i]>=l&&sum+arr[i]<=u){ sum+=arr[i]; q.push({arr[i],i}); break;} if (sum+arr[i]<=u){ sum+=arr[i]; q.push({arr[i],i}); } else { while(sum+arr[i]>u){ sum-=q.top().first; q.pop();} sum+=arr[i]; q.push({arr[i],i}); }} vector<int>ans; if (sum>=l&&sum<=u){ while(!q.empty()){ ans.push_back(q.top().second + 1); q.pop();} sort(ans.begin(),ans.end()); } return ans; }

Compilation message (stderr)

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