Submission #935798

#TimeUsernameProblemLanguageResultExecution timeMemory
935798SpyrosAlivDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms348 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>

vector<int> getans(int l, int r, vector<pll> w) {
    vector<int> a;
    for (int i = l; i < r; i++) {
        a.push_back(w[i].second);
    }
    return a;
}

vector<int> find_subset(int l, int u, vector<int> w) {
    int n = w.size();
    vector<pll> arr;
    for (int i = 0; i < n; i++) {
        arr.push_back({w[i], i});
    }
    sort(arr.begin(), arr.end());
    int le = 0, r = 0;
    ll currSum = 0;
    while (r < n) {
        while (currSum < l && r < n) {
            currSum += arr[r++].first;
        }
        while (currSum > u && le < r) {
            currSum -= arr[le++].first;
        }
        if (currSum >= l && currSum <= u) {
            return getans(le, r, arr);
        }
        if (r < n) currSum += arr[r++].first;
    }
    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...