Submission #789790

#TimeUsernameProblemLanguageResultExecution timeMemory
789790pravcoderDetecting Molecules (IOI16_molecules)C++17
46 / 100
3 ms980 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() - 1; int t = 0; while ((sum > u) && (t < start) && (r >= start)) { set[t] = t; sum -= m[r].first - m[t].first; r--; t++; } if (sum > u) return vi(0); vi 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++)
      |                  ~~^~~~~~~~~~
#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...