# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
645920 | GaLz | Detecting Molecules (IOI16_molecules) | C++14 | 55 ms | 7200 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 <bits/stdc++.h>
#include "molecules.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;
const ll maxn=2e5+5;
const int INF=1e8;
#define ok ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define endl '\n'
ll pref[maxn];
int pos;
vector<pii> isi;
vi find_subset(int l, int u, vi w) {
for(int i=0; i<w.size(); i++) {
isi.pb({w[i], i});
}
sort(isi.begin(), isi.end());
vi ans;
for(auto it : isi) {
pos++;
pref[pos]=it.fi;
pref[pos]+=pref[pos-1];
}
for(int i=1; i<=pos; i++) {
int lf=1, rg=i, can=0;
while(lf<=rg) {
int mid=(lf+rg)/2;
ll cur=pref[i]-pref[mid-1];
if(cur>=l && cur<=u) {
can=mid;
break;
} else if(cur<l) rg=mid-1;
else lf=mid+1;
}
if(can) {
for(int j=can-1; j<=i-1; j++) {
ans.pb(isi[j].se);
}
break;
}
}
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... |