# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
372588 | cpp219 | Detecting Molecules (IOI16_molecules) | C++14 | 1 ms | 384 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.
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 2e5 + 9;
const ll mod = 1e9 + 7;
vector<int> kq;
void Get_kq(deque<ll> &dq){
for (auto i : dq) kq.push_back(i);
}
vector<int> find_subset(int L,int R, vector<int> w){
deque<ll> ans;
vector<LL> a;
ll cur = 0; ll n = w.size();
for (ll i = 0;i < n;i++) a.push_back({w[i],i}); sort(a.begin(),a.end());
if (R < a[0].fs) return kq;
if (L <= a[0].fs&&a[0].fs <= R){
kq.push_back(a[0].sc); return kq;
}
if (L <= a[n - 1].fs&&a[n - 1].fs <= R){
kq.push_back(a[n - 1].sc); return kq;
}
//cout<<a[0].fs; exit(0);
for (ll i = 0;i < n;i++){
if (L <= cur&&cur <= R) break;
else if (cur + a[i].fs <= R) cur += a[i].fs,ans.push_back(a[i].sc);
else if (cur + a[i].fs > R){
while(i < n){
if (L <= cur&&cur <= R){
Get_kq(ans); return kq;
}
if (ans.empty()) break;
ll p = ans.front(); ans.pop_front();
ll val = a[i].fs - w[p];
if (cur + val <= R) cur += val,ans.push_back(a[i].sc); i++;
}
return kq;
}
}
Get_kq(ans); return kq;
}
/*
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#define task "test"
if (fopen(task".INP","r")){
freopen(task".INP","r",stdin);
//freopen(task".OUT","w",stdout);
}
ll L,R,n,x; vector<int> w;
cin>>n>>L>>R;
for (ll i = 1;i <= n;i++) cin>>x,w.push_back(x);
vector<int> c = find_subset(L,R,w); //return 0;
for (auto i : c) cout<<i<<" ";
}
*/
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... |