Submission #561554

#TimeUsernameProblemLanguageResultExecution timeMemory
561554HappyPacManDetecting Molecules (IOI16_molecules)C++14
69 / 100
41 ms5344 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l,int u,vector<int> w){ vector<pair<int,int> > vec; for(int i=0;i<w.size();i++){ vec.emplace_back(w[i],i); } sort(vec.rbegin(),vec.rend()); vector<int> res; int sum = 0; for(int i=0;i<vec.size();i++){ sum += vec[i].first; res.emplace_back(vec[i].second); if(sum >= l){ break; } } for(int i=0;i<res.size()&&res.size()<=vec.size()-i-1;i++){ if(sum <= u){ break; } sum += vec[vec.size()-i-1].first - w[res[i]]; res[i] = vec[vec.size()-i-1].second; } if(l <= sum && sum <= u){ return res; } vector<int> blank; return blank; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for(int i=0;i<w.size();i++){
      |                 ~^~~~~~~~~
molecules.cpp:13:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i=0;i<vec.size();i++){
      |                 ~^~~~~~~~~~~
molecules.cpp:20:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i=0;i<res.size()&&res.size()<=vec.size()-i-1;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...