Submission #582056

#TimeUsernameProblemLanguageResultExecution timeMemory
582056Soumya1Detecting Molecules (IOI16_molecules)C++17
100 / 100
61 ms4796 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { vector<int> order(w.size()); iota(order.begin(), order.end(), 0); sort(order.begin(), order.end(), [&](int i, int j) { return w[i] < w[j]; }); long long cur = 0; int ptr = 0; for (int i = 0; i < w.size(); i++) { while (cur < l && ptr < w.size()) cur += w[order[ptr]], ptr++; if (l <= cur && cur <= u) { vector<int> ans; for (int j = i; j < ptr; j++) ans.push_back(order[j]); return ans; } if (ptr > i) cur -= w[order[i]]; } return {}; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:10:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |   for (int i = 0; i < w.size(); i++) {
      |                   ~~^~~~~~~~~~
molecules.cpp:11:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     while (cur < l && ptr < w.size()) cur += w[order[ptr]], ptr++;
      |                       ~~~~^~~~~~~~~~
#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...