Submission #68966

#TimeUsernameProblemLanguageResultExecution timeMemory
68966KubalionzzaleRoller Coaster Railroad (IOI16_railroad)C++14
0 / 100
381 ms14516 KiB
#include "railroad.h" #include <iostream> #include <algorithm> #include <functional> #include <set> int n; std::pair<int, int> a[200010]; std::set< std::pair<int, int>, std::greater< std::pair<int, int> > > set; //first - output speed, second - index bool compare(const std::pair<int, int> &lhs, const std::pair<int, int> &rhs) { if (lhs.first != rhs.first) return lhs.second < rhs.second; else return lhs.first < rhs.first; } long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { n = (int) s.size(); for (int i = 0; i < n; ++i) { a[i].first = s[i]; a[i].second = t[i]; set.insert(std::make_pair(t[i], i)); } set.insert(std::make_pair(1, -1)); std::sort(a, a + n, compare); for (int i = 0; i < n; ++i) { auto it = set.lower_bound(std::make_pair(s[i], -1)); if (it == set.end()) return 0; set.erase(it); } return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...