Submission #1354608

#TimeUsernameProblemLanguageResultExecution timeMemory
1354608nataliaaDetecting Molecules (IOI16_molecules)C++20
9 / 100
0 ms344 KiB
#include<bits/stdc++.h>
#include "molecules.h"
using namespace std;
vector<int> find_subset(int L, int u,vector<int> w){
    int n = w.size();
    vector<pair<int, int>> p;
    vector<int> ans;
    for(int i = 0; i < n; i++) {
        p.push_back({w[i], i});
    }
    long long l = 0, r = 0, s = 0;
    while(l<n&&r<n) {
        if(s>=L&&s<=u){
            for(int i = l; i<=r; i++) ans.push_back(p[i].second);
            return ans;
        }
        //cout << s <<" "<< l <<" "<< r << endl;
        s+=p[r].first;
       //cout << L <<" "<< u<<endl;
        if(s>=L&&s<=u){
            for(int i = l; i<=r; i++) ans.push_back(p[i].second);
            return ans;
        }
        if(s<L) r++;
        else {
            s-=p[l].first;
            l++;
        }
    }
    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...