Submission #1004979

#TimeUsernameProblemLanguageResultExecution timeMemory
1004979MardonbekhazratovDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms348 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; int n; vector<int>ans; vector<int> find_subset(int l, int u, vector<int> w) { n=(int)w.size(); vector<pair<int,int>>a(n); for(int i=0;i<n;i++) a[i].first=w[i],a[i].second=i+1; sort(a.begin(),a.end()); int j=0; long long sum=0; for(int i=0;i<n;i++){ sum+=a[i].first; while(j<n && (a[i].first-a[j].first>u-l || sum>u)) sum-=a[j].first,j++; if(sum>=l && sum<=u){ for(int k=j;k<=i;k++) ans.push_back(k); return ans; } } return vector<int>(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...