Submission #811052

#TimeUsernameProblemLanguageResultExecution timeMemory
811052manhlinh1501Detecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
/// @author : Hoang Manh Linh
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

#define pll pair<i64, i64>
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define lb(a, x) lower_bound(all(a), x) - a.begin()

int n;
int l, r;

vector<i64> find_subset(i64 l, i64 r, vector<i64> a) {
    int n = a.size();
    vector<i64> sum(n);
    vector<pll> res;

    for(int i = 0; i < n; i++)
        res.eb(a[i], i);

    sum.front() = res.front().first;

    for(int i = 1; i < n; i++)
        sum[i] = sum[i - 1] + res[i].first;

    vector<int> ans;

    for(int i = 0; i < n; i++) {
        int pos = lb(sum, sum[i] - res[i].first + l);

        if(pos >= n)
            continue;

        if(sum[pos] - sum[i] + res[i].first <= r) {
            for(int j = i; j <= pos; j++)
                ans.eb(res[j].second + 1);

            break;
        }
    }

    return ans;
}

Compilation message (stderr)

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