Submission #1343636

#TimeUsernameProblemLanguageResultExecution timeMemory
1343636Born_To_LaughDetecting Molecules (IOI16_molecules)C++17
100 / 100
33 ms3752 KiB
// Born_To_Laugh - Hughie Do
#include "molecules.h"
#include <bits/stdc++.h>
#define alle(AC) AC.begin(), AC.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
[[maybe_unused]] const int MOD = 998244353, INF = 1e9 + 7;

vector<int> find_subset(int l, int u, vector<int> w){
    int n = w.size();
    vector<pair<int, int>> sth(n + 1);
    for(int i=1; i<=n; ++i){
        sth[i] = {w[i - 1], i - 1};
    }
    sort(sth.begin() + 1, sth.end());
    int lo = 1, hi = 0;
    ll sum = 0;
    while(1){
        if(l <= sum && sum <= u){
            vector<int> ans;
            for(int i=lo; i<=hi; ++i) ans.push_back(sth[i].se);
            return ans;
        }
        else if(sum < l){
            hi++;
            if(hi > n) return {};
            else sum += sth[hi].fi;
        }
        else{
            sum -= sth[lo].fi;
            lo++;
            if(lo > n) return {};
        }
    }
    return {};
}
// signed main(){
//     freopen("inp.txt", "r", stdin);
//     freopen("out.txt", "w", stdout);
//     ios_base::sync_with_stdio(false);
//     cin.tie(nullptr);
//     vector<int> ans = find_subset(10, 20, {15, 17, 16, 18});
//     for(auto &elm: ans) cout << elm << ' ';
// }
#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...