Submission #997671

#TimeUsernameProblemLanguageResultExecution timeMemory
997671AtinaRDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms432 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()); int i=0,j=0; int sum=0; int n=w.size(); while(j<n) { while(j<n && sum<l) { sum+=v[j].first; j++; } if(sum>=l && sum<=u) { vector<int> res; for(int k=i; k<j; k++) { res.push_back(v[k].second); } sort(res.begin(),res.end()); return res; } sum-=v[i].first; i++; } return {}; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:19: 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++)
      |                  ~^~~~~~~~~
#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...