Submission #547145

#TimeUsernameProblemLanguageResultExecution timeMemory
547145beedleDetecting Molecules (IOI16_molecules)C++17
19 / 100
1 ms304 KiB
#include <iostream> #include <iomanip> #include <vector> #include <algorithm> #include <set> #include <iterator> #include <stack> #include <map> #include <math.h> #include <bitset> #include <deque> #include <string> #include <tuple> #include <queue> #include <numeric> #include <unordered_set> #include <unordered_map> #define pi 3.141592653589793238 #define ll long long #define ld long double #define rep(i, a, b) for (long long i = a; i <= b; i++) #define mod 1000000007ll #define INF 1000000000000000000 #define pb push_back #define ff first #define ss second #define endl '\n' #define all(x) (x).begin (), (x).end () #define sz(x) (ll) (x).size () #define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin()) #define rank rnk #define log lg #define fast \ ios_base::sync_with_stdio (false); \ cin.tie (NULL); \ cout.tie (NULL) using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n=sz(w); vector <pair<int,int>> arr(n); rep(i,0,n-1) arr[i]={w[i],i}; int curr=0; vector <int> idx; bool done=false; int lidx=-1; rep(i,0,n-1) { curr+=arr[i].ff; idx.pb(arr[i].ss); lidx=i; if(curr>=l && curr<=u) { done=true; break; } else if(curr>u) { curr-=arr[i].ff; idx.pop_back(); lidx--; break; } } if(done) return idx; // cout<<curr<<endl; int fidx=0; rep(i,lidx+1,n-1) { curr+=arr[i].ff-arr[fidx].ff; idx.pb(arr[i].ss); fidx++; if(curr>=l && curr<=u) break; } int s=sz(idx); vector <int> ret; rep(i,fidx,s-1) ret.pb(idx[i]); // cout<<curr<<endl; if(curr>=l && curr<=u) return ret; else return vector <int> (); } // signed main() // { // fast; // freopen("milkorder.in","r",stdin); // freopen("milkorder.out","w",stdout); // auto v=find_subset(10,20, {15,17,16,18}); // for(auto x:v) // cout<<x<<" "; // return 0; // }
#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...