Submission #372308

#TimeUsernameProblemLanguageResultExecution timeMemory
372308mahmoudbadawyDetecting Molecules (IOI16_molecules)C++17
100 / 100
58 ms6260 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<pair<int,int> > v; for(int i=0;i<w.size();i++) v.push_back({w[i],i}); sort(v.begin(),v.end()); long long sum=0; int r=0; vector<int> ans; for(int i=0;i<v.size();i++) { while(r<v.size()&&sum<l) {sum+=v[r].first; r++;} if(sum<=u&&sum>=l) { for(int j=i;j<r;j++) ans.push_back(v[j].second); return ans; } sum-=v[i].first; if(sum<0) sum=0; } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for(int i=0;i<w.size();i++)
      |              ~^~~~~~~~~
molecules.cpp:14:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for(int i=0;i<v.size();i++)
      |              ~^~~~~~~~~
molecules.cpp:16:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |   while(r<v.size()&&sum<l) {sum+=v[r].first; r++;}
      |         ~^~~~~~~~~
#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...