Submission #1070752

#TimeUsernameProblemLanguageResultExecution timeMemory
1070752dostsDetecting Molecules (IOI16_molecules)C++17
100 / 100
44 ms10680 KiB
//Dost SEFEROĞLU #include "molecules.h" #include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define ff first #define ss second #define sp << " " << #define all(cont) cont.begin(),cont.end() #define vi vector<int> const int MOD = 1e9+7,inf = 2e18; const int N = 1e5+50; vector<int32_t> find_subset(int32_t l, int32_t u, vector<int32_t> w) { int n = w.size(); vector<pii> ps; for (int i=0;i<n;i++) ps.push_back({w[i],i}); sort(all(ps)); vi p(n,0); p[0] = ps[0].ff; for (int i=1;i<n;i++) p[i] = p[i-1]+ps[i].ff; int sm = 0; vector<int32_t> v; for (int i=0;i<n;i++) { if (sm >= l && sm <= u) { sort(all(v)); return v; } sm+=ps[i].ff; v.push_back(ps[i].ss); int L = 0; int R = i+1; while (L<=R){ int m = (L+R) >> 1; if (sm-(m?p[m-1]:0) <= u) R = m-1; else L = m+1; } int subt = L ? p[L-1] : 0; if (sm-subt >= l) { reverse(all(v)); for (int i=1;i<=L;i++)v.pop_back(); reverse(all(v)); sort(all(v)); return v; } } return vector<int32_t>{}; }
#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...