This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "railroad.h"
#include <iostream>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
int n;
std::pair<int, int> a[200010];
std::multimap< int, int, std::greater< int > > mapa;
//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];
mapa.insert(std::make_pair(t[i], 0));
}
mapa.insert(std::make_pair(1, 0));
int cnt = 1;
for (auto it = --(mapa.end());;)
{
it->second = cnt;
++cnt;
if (it == mapa.begin())
break;
else
--it;
}
std::sort(a, a + n, compare);
for (int i = 0; i < n; ++i)
{
auto it = mapa.lower_bound(s[i]);
if (it->second < (n - i))
return 1;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |