Submission #1268430

#TimeUsernameProblemLanguageResultExecution timeMemory
1268430MahogDetecting Molecules (IOI16_molecules)C++20
9 / 100
1 ms328 KiB
#include <bits/stdc++.h>
#include "molecules.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
const int MAX = 2e5 + 2;
ll id[MAX], a[MAX], n;

bool cmp(int x, int y) {
    return a[x] > a[y];
}

vector<int> find_subset(int l, int r, vector<int> w) {
    n = w.size();
    for (int i = 1; i <= n; i++) {
        id[i] = i;
        a[i] = w[i - 1];
    }
    sort(id + 1, id + n + 1, cmp);
    ll total = 0;
    int res = 0;
    for (int i = 1; i <= n; i++) {
        total += a[id[i]];
        if (total >= l && total <= r) {
            res = i;
            break;
        }
        if (total >= r) break;
    }
    vector<int> res1;
    if (res > 0) {
        for (int i = 1; i <= res; i++) res1.push_back(id[i] - 1);
    }
    return res1;
}

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...