Submission #378022

#TimeUsernameProblemLanguageResultExecution timeMemory
378022hackermubDetecting Molecules (IOI16_molecules)C++17
100 / 100
56 ms4972 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define float long double #define fi first #define se second #define pb push_back #define all(v) v.begin(),v.end() #define sz(v) (int)v.size() std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n=sz(w); vector<int> idx(n); iota(all(idx),0); sort(all(idx),[&w](int a,int b)->bool{ return w[a]<w[b]; }); int L=0,R=0; ll sum=w[idx[0]]; while(L<n && R<n && L<=R){ if(l<=sum && sum<=u) return vector<int>(idx.begin()+L,idx.begin()+R+1); if(sum<=l && R+1<n) sum+=w[idx[R+1]],R++; else sum-=w[idx[L]],L++; } return {}; }
#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...