Submission #598425

#TimeUsernameProblemLanguageResultExecution timeMemory
598425alirezasamimi100Detecting Molecules (IOI16_molecules)C++17
100 / 100
55 ms8600 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; using pii = pair<int,int>; using ll = long long int; #define pb push_back #define F first #define S second vector<int> find_subset(int l, int u, vector<int> w) { vector<pii> vec; vector<int> ans; vector<ll> ps={0}; int n=w.size(); for(int i=0; i<n; i++) vec.pb({w[i],i}); sort(vec.begin(),vec.end()); int L=-1,R; for(int i=0; i<n; i++){ ll x=ps.back()+vec[i].F; ps.pb(x); if(x<l) continue; if(x<=u){ L=0; R=i; break; } int t=lower_bound(ps.begin(),ps.end(),x-u)-ps.begin(); if(t<(int)ps.size() && x-ps[t]>=l){ L=t; R=i; break; } } if(L!=-1){ for(int i=L; i<=R; i++) ans.pb(vec[i].S); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...