Submission #61060

#TimeUsernameProblemLanguageResultExecution timeMemory
61060TenuunDetecting Molecules (IOI16_molecules)C++17
9 / 100
3 ms628 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, std::vector<int> w) { vector<int>res; vector<pair<int, int> >v; for(int i=0; i<w.size(); i++){ v.push_back({w[i], i}); } sort(v.rbegin(), v.rend()); long long curr=0; int L=0, r=0; while(L<v.size()){ r=max(r, L); if(L==r){ curr=v[L].first; res.clear(); res.push_back(v[L].second); } while(r+1<v.size() && curr<l){ curr+=v[r+1].first; res.push_back(v[r+1].second); r++; } if(curr>=l && curr<=u) return res; while(res.size() && curr>u){ curr-=v[L].first; swap(*res.begin(), *res.end()); res.pop_back(); L++; } if(curr>=l && curr<=u) return res; L++; } if(curr>=l && curr<=u) return res; else return res={}, res; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<w.size(); i++){
               ~^~~~~~~~~
molecules.cpp:15:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(L<v.size()){
        ~^~~~~~~~~
molecules.cpp:22:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(r+1<v.size() && curr<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...