Submission #686689

#TimeUsernameProblemLanguageResultExecution timeMemory
686689BliznetcDetecting Molecules (IOI16_molecules)C++17
69 / 100
112 ms14332 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define sz size() #define all(x) x.begin(), x.end() #define F first #define S second //#define int long long typedef pair < int, int > pii; typedef vector < int > vi; typedef vector < vi > vvi; std::vector<int> find_subset(int l, int r, std::vector<int> w) { int n = w.size(); pair<int,int> a[n]; for (int i = 0; i < n; i++) { a[i] = {w[i], i}; } sort (a, a + n); int cur = 0; int j = 0; int i = 0; set <int> d; while (j < n) { if (cur < l) { cur += a[j].F; d.insert(a[j].S); j++; } if (cur > r) { cur -= a[i].F; d.erase(a[i].S); i++; } if (cur >= l && cur <= r) { break; } } if (cur >= l && cur <= r) { return vector<int> (all(d)); } 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...