Submission #728372

#TimeUsernameProblemLanguageResultExecution timeMemory
728372sofija6Detecting Molecules (IOI16_molecules)C++14
0 / 100
2 ms340 KiB
#include <bits/stdc++.h> #include "molecules.h" #define MAXN 100010 using namespace std; int W[MAXN],n; vector<int> find_subset(int l, int u, vector<int> w) { int L=0,R=0,sum=w[0]; vector<int> ans; vector<pair<int,int> > a; for (int i=0;i<n;i++) a.push_back({w[i],i}); sort(a.begin(),a.end()); for (int i=1;i<n;i++) { if (sum+a[i].first<=u) { sum+=a[i].first; R=i; } } if (sum>=l && sum<=u) { ans.clear(); for (int j=L;j<=R;j++) ans.push_back(a[j].second); return ans; } for (int i=R+1;i<n;i++) { if (sum>=l && sum<=u) { ans.clear(); for (int j=L;j<=R;j++) ans.push_back(a[j].second); break; } sum-=a[L].first; L++; R++; sum+=a[R].first; } 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...