Submission #31071

#TimeUsernameProblemLanguageResultExecution timeMemory
31071platinantDetecting Molecules (IOI16_molecules)C++14
100 / 100
76 ms5340 KiB
#include "molecules.h" #include <algorithm> using namespace std; typedef pair<int,int> pp; vector<int> find_subset(int l, int u, vector<int> w) { vector<int> ret; vector<pp> a(w.size()); for(int i=0;i<w.size();i++){ a[i]=pp(w[i],i); } sort(a.begin(),a.end()); long long int len=0,sum=0; while(len<a.size()&&sum<l){ sum+=a[len].first; len++; } if(sum<l)return vector<int>(0); if(sum<=u){ for(int i=0;i<len;i++)ret.push_back(a[i].second); return ret; } if(len==1)return vector<int>(0); sum -= a[len-1].first; int L=1, R=len-1; for(;R<w.size();R++,L++){ sum+=a[R].first-a[L-1].first; if(sum>=l){ for(int i=L;i<=R;i++)ret.push_back(a[i].second); return ret; } } return vector<int>(0); }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:11:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<w.size();i++){
               ^
molecules.cpp:18:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(len<a.size()&&sum<l){
           ^
molecules.cpp:32:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(;R<w.size();R++,L++){
        ^
#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...