Submission #617756

#TimeUsernameProblemLanguageResultExecution timeMemory
617756Bench0310Detecting Molecules (IOI16_molecules)C++17
19 / 100
1 ms300 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; typedef long long ll; vector<int> find_subset(int L,int R,vector<int> w) { int n=w.size(); vector<array<int,2>> a(n); for(int i=0;i<n;i++) a[i]={w[i],i}; sort(a.begin(),a.end()); int c=0; ll s=0; while(c<n&&s<L) { c++; s+=a[n-c][0]; } if(s<L) return {}; ll t=0; for(int i=0;i<c;i++) t+=a[i][0]; if(t>R) return {}; int d=0; while(s>R) { s+=a[d][0]; s-=a[n-1-d][0]; d++; } assert(L<=s&&s<=R); vector<int> res; for(int i=0;i<d;i++) res.push_back(a[i][1]); for(int i=0;i<c-d;i++) res.push_back(a[n-1-i][1]); return res; }
#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...