| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1289278 | hssaan_arif | Detecting Molecules (IOI16_molecules) | C++20 | 2 ms | 348 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;
vector<int> ans;
sort(w.rbegin(),w.rend());
for (int i=0 ; i <w.size() ; i++){
su += w[i].fi;
ans.pb(w[i].se);
if (l <= su && su <= u){
return ans;
}
if (su > u){
int f = i+1;
while(f--){
su -= w[i].fi;
ans.pop_back();
su += w[ls].fi;
ans.pb(w[ls].se);
i--;
ls--;
if (l <= su && su <= u){
return ans;
}
}
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... | ||||
