Submission #483379

#TimeUsernameProblemLanguageResultExecution timeMemory
483379DavidDamianDetecting Molecules (IOI16_molecules)C++11
69 / 100
42 ms5532 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int r, vector<int> w) { vector< pair<int, int> > elements; for(int i = 0; i < w.size(); i++){ elements.push_back({w[i], i}); } sort(elements.begin(), elements.end()); vector<int> indices; int sumEl = 0, i = 0, j = 0; while(j <= elements.size()){ if(sumEl < l){ if (j == elements.size()) break; sumEl+=elements[j++].first; }else if(sumEl > r){ sumEl-=elements[i++].first; } if(sumEl >= l && sumEl <= r) break; } if(sumEl >= l && sumEl <=r){ while(i<j) indices.push_back(elements[i++].second); } return indices; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:22: 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:17:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     while(j <= elements.size()){
      |           ~~^~~~~~~~~~~~~~~~~~
molecules.cpp:19:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |             if (j == elements.size()) break;
      |                 ~~^~~~~~~~~~~~~~~~~~
#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...