Submission #69016

#TimeUsernameProblemLanguageResultExecution timeMemory
69016KubalionzzaleRoller Coaster Railroad (IOI16_railroad)C++14
0 / 100
336 ms28936 KiB
#include "railroad.h" #include <iostream> #include <algorithm> #include <functional> #include <set> #include <map> int n; std::pair<int, int> a[200010]; std::multiset< int, std::greater<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.first < rhs.first; else return lhs.second < rhs.second; } 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(a[i].second); } set.insert(1); std::sort(a, a + n, compare); bool flag = false; for (int i = 0; i < n; ++i) { if (set.find(a[i].second) != set.end()) flag = true; if (flag) set.erase(set.find(a[i].second)); auto it = set.lower_bound(a[i].first); if (it == set.end()) return 1; set.erase(it); if (flag) set.insert(a[i].second); } return 0; }

Compilation message (stderr)

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:42:7: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
       if (flag)
       ^~
railroad.cpp:44:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
         auto it = set.lower_bound(a[i].first);
         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...