Submission #1064555

# Submission time Handle Problem Language Result Execution time Memory
1064555 2024-08-18T14:29:46 Z Rigobertus Detecting Molecules (IOI16_molecules) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include "molecules.h"
using namespace std;

vector<int> find_subset(long long l, long long u, vector<long long> w) {
    long long n = w.size();
    vector<pair<long long, long long>> v;
    vector<long long> result;
    for (int i = 0; i < n; i++) {
        v.push_back({ w[i], i + 1 });
    }
    sort(w.begin(), w.end());
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        sum += w[i];
    }
    for (int i = n - 1; i >= 0; i--) {
        if (sum - v[i].first < l) {
            result.push_back(v[i].second);
        }
        else {
            sum -= v[i].first;
        }
    }
    if (sum < l || sum > u) {
        return {};
    }
    sort(result.begin(), result.end());
    return result;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(long long int, long long int, std::vector<long long int>)':
molecules.cpp:33:12: error: could not convert 'result' from 'vector<long long int>' to 'vector<int>'
   33 |     return result;
      |            ^~~~~~
      |            |
      |            vector<long long int>