Submission #1018870

#TimeUsernameProblemLanguageResultExecution timeMemory
1018870AlgorithmWarriorDetecting Molecules (IOI16_molecules)C++14
69 / 100
29 ms6092 KiB
#include <cstdio> #include <vector> #include <cassert> #include <algorithm> #include "molecules.h" using namespace std; struct str { int val; int ind; }; bool crt(str a,str b) { return a.val<b.val; } vector<int> find_subset(int l, int u, vector<int> w) { vector<str>date(w.size()); int i; for(i=0;i<date.size();++i) date[i]={w[i],i}; sort(date.begin(),date.end(),crt); vector<int>res; int total=0; for(i=date.size()-1;i>=0;--i) { total+=date[i].val; res.push_back(date[i].ind); if(l<=total && total<=u) return res; if(total>u) break; } if(i==-1) return vector<int>(0); int care; for(care=0;i<date.size();++i,++care) { total-=date[i].val; total+=date[care].val; res[res.size()-1-care]=date[care].ind; if(l<=total && total<=u) return res; } return vector<int>(0); }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:24:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<str>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(i=0;i<date.size();++i)
      |             ~^~~~~~~~~~~~
molecules.cpp:41:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<str>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(care=0;i<date.size();++i,++care)
      |                ~^~~~~~~~~~~~
#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...