| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1289335 | hssaan_arif | Detecting Molecules (IOI16_molecules) | C++20 | 82 ms | 12824 KiB |
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
#define endl "\n"
#define pb push_back
// #define int long long
#define fi first
#define se second
const int N = 3e5 + 5, M = 1e9 + 7, LG = 20;
int n;
vector<int> find_subset(int l, int u, vector<int> w1) {
vector<pair<int,int>> w;
for (int i=0; i<w1.size() ; i++){
w.pb({w1[i],i});
}
int su = 0 , ls = w.size()-1;
// cout << ls << endl;
set<int> ans;
sort(w.rbegin(),w.rend());
for (int i=0 ; i <w.size() ; i++){
su += w[i].fi;
ans.insert(w[i].se);
if (l <= su && su <= u){
vector<int> g;
for (auto i : ans) g.pb(i);
return g;
}
if (su > u){
int f = i+1;
while(f--){
su -= w[i].fi;
ans.erase(w[i].se);
su += w[ls].fi;
ans.insert(w[ls].se);
i--;
ls--;
if (l <= su && su <= u){
vector<int> g;
for (auto i : ans) g.pb(i);
return g;
}
}
return vector<int>(0);
}
}
return vector<int>(0);
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
