Submission #93472

#TimeUsernameProblemLanguageResultExecution timeMemory
93472tpoppoDetecting Molecules (IOI16_molecules)C++14
100 / 100
52 ms7164 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll,int>; vector<int> res; vector<pii> v; vector<int> find_subset(int lw, int u, vector<int> w) { v.reserve(w.size()); for(int i=0;i<w.size();i++){ v.emplace_back(w[i],i); } sort(v.begin(),v.end()); int l = 0; ll sum = 0; for(int r = 0;r < v.size();r++){ sum += v[r].first; while(sum > u){ sum -= v[l].first; l++; } //cout<<l<<" - "<<r<<": "<<sum<<endl; if(sum >= lw){ for(int i = l;i<=r;i++) res.push_back(v[i].second); return res; } } return vector<int>(); }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:15:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<w.size();i++){
               ~^~~~~~~~~
molecules.cpp:22:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int r = 0;r < v.size();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...