Submission #729145

#TimeUsernameProblemLanguageResultExecution timeMemory
729145NintsiChkhaidzeDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms312 KiB
#include <bits/stdc++.h> #define pb push_back #define f first #define s second #include "molecules.h" using namespace std; const int N = 2e5 + 5; vector <pair <int,int> > a; int p[N]; vector<int> find_subset(int L, int R, vector<int> w) { int n = w.size(); for (int i = 0; i < n; i++) a.pb({w[i],i}); sort(a.begin(),a.end()); for (int i= 0;i<n;i++){ p[i] = a[i].f; if (i) p[i] += p[i - 1]; } vector <int> ans; ans.clear(); for (int i =0;i<n;i++){ int l = i + 1,r = n - 1,res = i; while (l <= r){ int mid = (l + r)>>1,sum = p[mid]; if (i) sum -= p[i - 1]; if (sum >= l){ res = mid; r = mid - 1; } else{ l = mid + 1; } } int s = p[res]; if (i) s-= p[i - 1]; if (L <= s && s <= R){ for (int j = i; j <= res; j++) ans.pb(a[j].s); break; } } 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...