# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
841067 | manhlinh1501 | Detecting Molecules (IOI16_molecules) | C++17 | 45 ms | 8500 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>
using namespace std;
using i64 = long long;
using pii = pair<int,int>;
using pli = pair<i64,int>;
#define sz(a) (int)a.size()
#define eb emplace_back
#define all(a) a.begin(),a.end()
int search(int first,int second,int k,vector<pli> &a){
int l=first,r=second;
int pos=-1;
while(l<=r){
int m=l+r>>1;
if(a[m].first-a[first-1].first>=k){
pos=m;
r=m-1;
}
else l=m+1;
}
return pos;
}
vector<int> find_subset(int l, int r, vector<int> a){
int n = sz(a);
vector<pii> res;
for(int i=0;i<n;i++)
res.eb(a[i],i);
sort(all(res));
vector<pli> sum(n+1,{0,0});
for(int i=0;i<n;i++){
sum[i+1].first=sum[i].first+res[i].first;
sum[i+1].second=res[i].second;
}
vector<int> ans;
for(int i=1;i<=n;i++){
// for(int j=i;j<=n;j++){
// i64 res=sum[j].first-sum[i-1].first;
// if(l<=res and res<=r){
// for(int k=i;k<=j;k++)
// ans.eb(sum[k].second);
// sort(all(ans));
// return ans;
// }
// }
int pos=search(i,n,l,sum);
if(pos==-1)
continue;
if(sum[pos].first-sum[i-1].first<=r){
// for(int j=i;j<=pos;j++)
// cout<<sum[j].second<<" ";
// cout<<"\n";
for(int j=i;j<=pos;j++)
ans.eb(sum[j].second);
break;
}
}
sort(all(ans));
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... |