Submission #1003531

#TimeUsernameProblemLanguageResultExecution timeMemory
1003531zh_hDetecting Molecules (IOI16_molecules)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> #define lint long long int #define pb push_back using namespace std; vector<int> find_subset(int l, int u, vector<int> w){ sort(w.begin(), w.end()); int ll = 0, rr = 0; int sum = w[0]; bool check = true; while(!(sum <= u && sum >= l)){ if(ll > rr){check = false; break;} else if(ll < 0){check = false; break;} else if(rr > w.size()-1){check = false; break;} else if(sum > u){ sum-= w[ll]; ll++; } else if(sum < l){ rr++; sum+=w[rr]; } // cout << ll << " " << rr << endl; } vector<int> ans; if(!check){return ans;} else{ for(int i = ll; i <= rr; i ++){ ans.pb(w[i]); } return ans; } } // int main(){ // vector<int> temp; // // temp = find_subset(15, 17, {6, 8, 8, 7}); // // temp = find_subset(10, 20, {15, 17, 16, 18}); // temp = find_subset(14, 15, {5, 5, 6, 6}); // for(auto i : temp){cout << i << " ";} cout << endl; // }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         else if(rr > w.size()-1){check = false; 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...