Submission #419278

#TimeUsernameProblemLanguageResultExecution timeMemory
419278Mohammed_AtalahDetecting Molecules (IOI16_molecules)C++17
69 / 100
53 ms4556 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { std::vector< pair <int, int> > nums; for (int i = 0; i < w.size(); i++) { if (w[i] >= l && w[i] <= u) { std::vector<int> p; p.push_back(i); return p; } else if (w[i] > u) { continue; } nums.push_back(make_pair(w[i], i)); } if (nums.size() == 0) { std::vector<int> v; return v; } sort(nums.begin(), nums.end()); bool there = false; int len = nums.size(); int left = 0; int right = 0; int total = nums[0].first; while (left < len && right < len) { if (total <= u && total >= l) { there = true; break; } else if (total < l) { right++; if (right < len) { total += nums[right].first; } } else if (total > u) { total -= nums[left].first; left++; } } if (there == true) { std::vector<int> res; for (int i = left; i < right + 1; i++) { res.push_back(nums[i].second); } return res; } std::vector<int> v; return v; }

Compilation message (stderr)

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