Submission #1354613

#TimeUsernameProblemLanguageResultExecution timeMemory
1354613takoshanavaDetecting Molecules (IOI16_molecules)C++20
100 / 100
27 ms4124 KiB
#include <bits/stdc++.h>
#include "molecules.h"
#define pb push_back
#define fs first
#define sc second
using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
    int n = w.size();
    vector<pair<int, int>> p;
    
    for(int i=0; i<n; i++) p.pb({w[i], i});
    sort(p.begin(), p.end());
   
    vector<int> ans;
    long long sum = 0;
    int j = 0;
    for(int i = 0; i < n; i++){
        sum += p[i].fs;
        while(j <= i and sum > u){
            sum -= p[j].fs;
            j++;
        }
        if(sum >= l and sum <= u){
            for(int h = j; h <= i; h++){
                ans.pb(p[h].sc);
            }
            return ans;
        }
    }

    return ans;
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...