| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1323443 | rafsanamin2020 | Detecting Molecules (IOI16_molecules) | C++20 | 33 ms | 6164 KiB |
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
/// @brief [purai wrong approach 🔥]
typedef long long int ll;
std::vector<int> find_subset(int l, int u, std::vector<int> w)
{
vector<int> ret;
ll psum = 0;
int n = w.size();
vector<pair<ll, ll>> ww(n, pair<ll, ll>({0, 0}));
for (int i = 0; i < n; i++)
{
ww[i].first = w[i];
ww[i].second = i;
}
sort(ww.begin(), ww.end());
// for (int i = 0; i < n; i++)
// {
// cout << ww[i].first << " " << ww[i].second << ">\n";
// }
bool possible = false;
for (int i = 0; i < n; i++)
{
int wgt = ww[i].first;
int idx = ww[i].second;
psum += wgt;
ret.push_back(idx);
if (psum > u)
{
psum -= wgt;
ret.pop_back();
break;
}
else if (psum >= l)
{
possible = true;
break;
}
}
if (!possible)
{
for (int i = 0, j = n - 1; i < ret.size() && ret.size() - 1 < j; i++, j--)
{
psum -= w[ret[i]];
ret[i] = ww[j].second;
psum += ww[j].first;
if (psum >= l)
{
possible = true;
break;
}
}
}
return possible ? ret : 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... | ||||
