Submission #1042764

#TimeUsernameProblemLanguageResultExecution timeMemory
1042764ZicrusDetecting Molecules (IOI16_molecules)C++17
10 / 100
1 ms432 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; typedef long long ll; vector<int> find_subset(int l, int u, vector<int> w) { ll n = w.size(); vector<pair<ll, ll>> s(n); for (int i = 0; i < n; i++) { s[i] = {w[i], i}; } sort(s.begin(), s.end()); ll tot = 0; vector<int> res; for (auto &e : s) { if (tot + e.first <= u) { tot += e.first; res.push_back(e.second); } else break; } ll id = n-1; ll resId = 0; while (tot < l && id >= res.size()) { tot += s[id].first - s[resId].first; res[resId] = s[id].second; id--; resId++; } return tot < l ? vector<int>() : res; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:27:26: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     while (tot < l && id >= res.size()) {
      |                       ~~~^~~~~~~~~~~~~
#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...