Submission #670962

#TimeUsernameProblemLanguageResultExecution timeMemory
670962mdubDetecting Molecules (IOI16_molecules)C++14
100 / 100
48 ms6160 KiB
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
vector<int> find_subset(int l, int u, vector<int> w) {
  vector<pair<int, int>> a;
  for (int i = 0; i < w.size(); i++) {
    a.push_back({w[i], i});
  }
  sort(a.begin(), a.end());
  int left = 0;
  LL sum = 0;
  for (int right = 0; right < w.size(); right++) {
    sum += a[right].first;
    while (sum > LL(u)) {
      sum -= a[left].first;
      left++;
    }
    if (sum >= LL(l)) {
      vector<int> ret;
      for (int i = left; i <= right; i++) {
	ret.push_back(a[i].second);
      }
      return ret;
    }
  }
  return {};
}

Compilation message (stderr)

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