Submission #931398

#TimeUsernameProblemLanguageResultExecution timeMemory
931398mariaclaraDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms444 KiB
#include "molecules.h"
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 1e5+5;
#define all(x) x.begin(), x.end()
#define mk make_pair
#define pb push_back
#define f first
#define s second

vector<int> find_subset(int l, int u, vector<int> w) {
    int n = w.size(), t = 0, sum = 0;
    vector<int> prefix(n+1);
    vector<pii> v(n);

    for(int i = 0; i < n; i++)
        v[i] = {w[i], i};

    sort(all(w));
    sort(all(v));

    for(int i = 1; i <= n; i++)
        prefix[i] = w[i-1] + prefix[i-1];

    for(int i = 0; i < n; i++) {
        sum += w[i];
        if(sum > l) { sum -= w[i]; t = i; break; }
    }

    for(int i = 0; i <= n-t; i++) {
        if(u >= prefix[i+t] - prefix[i] and prefix[i+t] - prefix[i] >= l) {
            vector<int> resp;
            for(int j = i; j < i+t; j++) resp.pb(v[j].s);
            return resp;
        }
    }

    return vector<int>(0);
}
#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...