Submission #759793

#TimeUsernameProblemLanguageResultExecution timeMemory
759793raysh07Detecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;

std::vector<int> find_subset(int l, int r, std::vector<int> w) {
    int n = b.size();
    vector <pair<int, int>> a(n);
    for (int i = 0; i < n; i++){
        a[i] = make_pair(w[i], i);
    }
    sort(a.begin(), a.end());
    vector <int> p(n + 1, 0);
    for (int i = 1; i <= n; i++) p[i] = p[i - 1] + a[i - 1].first;
    
    for (int i = 1; i <= n; i++){
        int mi = p[i];
        int mx = p[n] - p[n - i];
        
        if (mx < l || mi > r) continue;
        
        for (int j = i; j <= n; j++){
            int sum = p[j] - p[j - i];
            if (sum >= l && sum <= r){
                vector <int> ans;
                for (int k = j - i + 1; k <= j; k++) ans.push_back(a[k - 1].second);
                return ans;
            }
        }
    }
    return std::vector<int>(0);
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:6:13: error: 'b' was not declared in this scope
    6 |     int n = b.size();
      |             ^