Submission #582052

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

Compilation message (stderr)

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