Submission #769364

#TimeUsernameProblemLanguageResultExecution timeMemory
769364Mery2005Detecting Molecules (IOI16_molecules)C++14
31 / 100
3 ms980 KiB
#include <iostream> #include <algorithm> #include <queue> #include <cmath> #include <vector> #include <list> #include <string> #include <unordered_map> #include <map> #include <set> #include <stack> #include <string> #include <iomanip> #include <fstream> using namespace std; void fastio() { ios_base::sync_with_stdio(false); cin.tie(0); } const long long mod = 1e9+7; const int N = 3e5+5; int a[N] , dp[N]; vector<int> find_subset(int l, int u, vector<int> w){ int n = w.size(); vector<pair<int , int>> w1; for(int i = 0 ; i < w.size() ; i++){ w1.push_back({w[i] , i}); } sort(w1.begin() , w1.end()); int ind = 0; int s = 0; for(int i = 0 ; i < n ; i++){ while(s < l){ s += w1[ind].first; ind++; } if(s >= l && s <= u){ vector<int> res; for (int j = i; j < ind; j++) { res.push_back(w1[j].second); } return res; } s -= w1[i].first; } return vector<int>(0); } // int main(){ // vector<int> ans = find_subset(15, 17, {6, 8, 8, 7}); // for(auto x : ans){ // cout << x << endl; // } // return 0; // }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:30:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   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...