Submission #1260851

#TimeUsernameProblemLanguageResultExecution timeMemory
1260851antonnDetecting Molecules (IOI16_molecules)C++20
100 / 100
32 ms2888 KiB
#include "molecules.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

vector<int> find_subset(int l, int u, vector<int> w) {
    int n = w.size();
    vector<int> ord(n);
    iota(ord.begin(), ord.end(), 0);
    sort(ord.begin(), ord.end(), [&](int x, int y) {
        return w[x] < w[y];
    });
    int j = 0;
    ll s = 0;
    for (int i = 0; i < n; ++i) {
        while (j < n && s < l) {
            s += w[ord[j]];
            ++j;
        }
        if (l <= s && s <= u) {
            vector<int> res;
            for (int k = i; k < j; ++k) res.push_back(ord[k]);
            return res;
        }
        s -= w[ord[i]];
    }
    return {};
}

Compilation message (stderr)

molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...