# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
342126 | Karliver | Detecting Molecules (IOI16_molecules) | C++14 | 78 ms | 7168 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "molecules.h"
#include <bits/stdc++.h>
#include <fstream>
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(12)<<(x)
#define all(v) (v).begin(), (v).end()
using namespace std;
#define forn(i, b) for (int i=0; i<b; ++i)
using ll = long long;
const int mod = (ll)998244353;
#define PI acos(-1)
typedef pair<int , int> pairs;
typedef complex<ll> G;
const int INF = 1e9 + 1;
const int N = 2e6 + 2;
const double eps = 1e-7;
vector<int> find_subset(int l, int r, vector<int> a) {
int n = a.size();
vector<pairs>b(n);
for(int i = 0;i < n; ++i) {
b[i] = {a[i], i};
}
sort(b.begin(), b.end());
sort(a.begin(), a.end());
vector<ll>pre(n + 1, 0);
pre[0] = 0;
for(int i = 0;i < n; ++i) {
pre[i + 1] = pre[i] + a[i];
}
auto cmp = [&](int pos) {
int ls = a[pos] + r - l;
int low = pos;
int high = upper_bound(a.begin() + pos, a.end(), ls) - a.begin();
--high;
int ans = -1;
while(low < high) {
int mid = (low + high) / 2;
ll ps = pre[mid + 1] - pre[pos];
if(ps >= l && ps <= r ) {
ans = mid;
break;
}
if(ps < l) {
low = mid + 1;
}
else high = mid;
}
ll ss = pre[low + 1] - pre[pos];
if(ss >= l && ss <= r) ans = low;
return ans;
};
int st = -1;
int ed = -1;
for(int i = 0;i < n; ++i) {
int ans = cmp(i);
if(ans == -1)continue;
st = i;
ed = ans;
break;
}
if(st == -1)return vector<int>(0);
int sz = ed - st + 1;
vector<int>ans;
for(int i = st;i <= ed;++i)ans.push_back(b[i].second);
return ans;
}
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... |