Submission #1018270

#TimeUsernameProblemLanguageResultExecution timeMemory
1018270eldorbek_008Detecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms360 KiB
#include "molecules.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
  vector<int> ans;
  int n = (int)w.size();
  vector<pair<int, int>> a;
  for (int i = 0; i < n; i++) {
    a.emplace_back(w[i], i);
  }
  sort(a.begin(), a.end());
  int i, j;
  i = j = 0;
  int sum = 0;
  while (i < n && j < n) {
    sum += a[j].first;
    while (sum > u) {
      sum -= a[i].first;
      i += 1;
    }
    if (l <= sum && sum <= u) {
      for (int i_ = i; i_ <= j; i_++) {
        ans.push_back(a[i_].second + 1);
      }
      return ans;
    }
    j += 1;
  }
  return {};
}
#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...