Submission #600440

#TimeUsernameProblemLanguageResultExecution timeMemory
600440A_DDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms212 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { set<int> st; vector<int> vec; int n=w.size(); vector<pair<int,int>> s; for(int i=0;i<w.size();i++){ s.push_back({w[i],i}); } sort(s.begin(),s.end()); if(s[0].first>u)return vec; int sum=0,l1=0,r1=0; while(r1<n){ if(l<=sum&&sum<=u)break; if(sum<l){ r1++; if(r1==n)break; sum+=s[r1].first; st.insert(s[r1].second); } else{ st.erase(s[l1].second); sum-=s[l1].first; l1++; } } for(auto x:st)vec.push_back(x); if(sum<l||sum>u){ vec.clear(); } sort(vec.begin(),vec.end()); return vec; }

Compilation message (stderr)

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