# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1232093 | cpdreamer | Detecting Molecules (IOI16_molecules) | C++20 | 35 ms | 5192 KiB |
#include "molecules.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long INF = 1e17;
typedef long long ll;
const ll MOD = 1000002022;
#define F first
#define P pair
#define S second
#define pb push_back
#define V vector
#define all(v) v.begin(), v.end()
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n=(int)w.size();
for (int i=0;i<n;i++) {
if (w[i]>=l && w[i]<=u) {
return {i};
}
}
V<P<ll,int>>vp(n);
for (int i=0;i<n;i++) {
vp[i]={w[i],i};
}
sort(all(vp));
ll s=vp[0].F;
int p1=0,p2=0;
while (p2<n && p1<n) {
if (s>=l && s<=u) {
V<int>id;
for (int i=p1;i<=p2;i++) {
id.pb(vp[i].S);
}
return id;
}
if (s>u) {
if (p1<n) {
s-=vp[p1].F;
}
p1++;
}
else {
p2++;
if (p2<n) {
s+=vp[p2].F;
}
}
}
return {};
}
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... |