Submission #103922

#TimeUsernameProblemLanguageResultExecution timeMemory
103922HideoDetecting Molecules (IOI16_molecules)C++14
100 / 100
381 ms25272 KiB
#include "molecules.h" #include <bits/stdc++.h> //#include "grader.cpp" using namespace std; #define ll long long #define pb push_back #define mk make_pair #define fr first #define sc second #define vi vector < int > #define pi pair < int, int > const int N = 2e5 + 7; int n, lf; ll s; vi ans, h, pos[N]; map < int, int > mp; std::vector<int> find_subset(int l, int u, std::vector <int> w) { h = w; n = w.size(); sort(h.begin(), h.end()); for (int i = 0; i < n; i++) if (!i || h[i] != h[i - 1]) mp[h[i]] = i; for (int i = 0; i < n; i++) pos[mp[w[i]]].pb(i); for (int i = 0; i < n; i++){ s += h[i]; if (s > u){ s -= h[lf]; lf++; } if (s >= l){ for (int j = lf; j <= i; j++){ ans.pb(pos[mp[h[j]]].back()); pos[mp[h[j]]].pop_back(); } 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...