Submission #1299613

#TimeUsernameProblemLanguageResultExecution timeMemory
1299613alexiahDetecting Molecules (IOI16_molecules)C++20
100 / 100
34 ms5292 KiB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
    long long n = w.size();
    vector<pair<long long , long long>> v(n);
    for(long long i = 0; i < n; i++){
        v[i].first = w[i]; v[i].second = i;
    }
    sort(v.begin() , v.end());
    long long count = v[0].first;
    long long ini = 0 , fin = 0;
    while(true){
        if(ini > fin){
            fin++; count += v[fin].first;
        }
        if(count > u){
            count -= v[ini].first; ini++;
        }
        else if(count < l){
            fin++;
            if(fin >= n){
                return {};
            }
            count += v[fin].first;
        }
        if(count >= l && count <= u){
            vector<int> ans;
            for(; ini <= fin; ini++) ans.push_back(v[ini].second);
            return ans;
        }
    }
    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...