Submission #789789

#TimeUsernameProblemLanguageResultExecution timeMemory
789789pravcoderDetecting Molecules (IOI16_molecules)C++14
19 / 100
1 ms340 KiB
#include "molecules.h" #include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; typedef vector<int> vi; typedef pair<int, int> pi; typedef vector<pi> vpi; typedef long long ll; vi find_subset(int l, int u, vi w) { vpi m; for (int i = 0; i < w.size(); i++) { m.push_back({ w[i], i }); } sort(m.begin(), m.end()); int start = m.size() - 1; ll sum = m[start].first; vi set = { start }; while (sum < l) { start--; sum += m[start].first; set.push_back(start); } int r = m.size(); int t; while ((sum > u) && (r > m.size()/2 - 1) && (r >= start)) { r--; t = m.size() - r - 1; if (t < start) { set[t] = t; sum -= m[r].first - m[t].first; } } vi ans; if (sum > u) return ans; for (auto mol : set) { ans.push_back(m[mol].second); } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'vi find_subset(int, int, vi)':
molecules.cpp:16:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for (int i = 0; i < w.size(); i++)
      |                  ~~^~~~~~~~~~
molecules.cpp:31:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  while ((sum > u) && (r > m.size()/2 - 1) && (r >= start)) {
      |                       ~~^~~~~~~~~~~~~~~~
#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...