Submission #69066

# Submission time Handle Problem Language Result Execution time Memory
69066 2018-08-19T18:12:08 Z Kubalionzzale Roller Coaster Railroad (IOI16_railroad) C++14
30 / 100
542 ms 80500 KB
#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);
  for (int i = 0; i < n; ++i)
  {
    bool flag = false;
    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;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB n = 2
2 Correct 2 ms 384 KB n = 2
3 Correct 2 ms 456 KB n = 2
4 Correct 3 ms 532 KB n = 2
5 Correct 2 ms 540 KB n = 2
6 Incorrect 2 ms 548 KB answer is not correct: 1 instead of 523688153
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB n = 2
2 Correct 2 ms 384 KB n = 2
3 Correct 2 ms 456 KB n = 2
4 Correct 3 ms 532 KB n = 2
5 Correct 2 ms 540 KB n = 2
6 Incorrect 2 ms 548 KB answer is not correct: 1 instead of 523688153
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 393 ms 14576 KB n = 199999
2 Correct 286 ms 14672 KB n = 199991
3 Correct 274 ms 18684 KB n = 199993
4 Correct 344 ms 18684 KB n = 152076
5 Correct 150 ms 18684 KB n = 93249
6 Correct 303 ms 25940 KB n = 199910
7 Correct 332 ms 28948 KB n = 199999
8 Correct 295 ms 31844 KB n = 199997
9 Correct 378 ms 32944 KB n = 171294
10 Correct 252 ms 33676 KB n = 140872
11 Correct 240 ms 40448 KB n = 199886
12 Correct 253 ms 43664 KB n = 199996
13 Correct 347 ms 46756 KB n = 200000
14 Correct 331 ms 49596 KB n = 199998
15 Correct 302 ms 52620 KB n = 200000
16 Correct 264 ms 56032 KB n = 199998
17 Correct 274 ms 59852 KB n = 200000
18 Correct 258 ms 62836 KB n = 190000
19 Correct 349 ms 65500 KB n = 177777
20 Correct 168 ms 65500 KB n = 100000
21 Correct 424 ms 72896 KB n = 200000
22 Correct 314 ms 76796 KB n = 200000
23 Correct 542 ms 80500 KB n = 200000
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB n = 2
2 Correct 2 ms 384 KB n = 2
3 Correct 2 ms 456 KB n = 2
4 Correct 3 ms 532 KB n = 2
5 Correct 2 ms 540 KB n = 2
6 Incorrect 2 ms 548 KB answer is not correct: 1 instead of 523688153
7 Halted 0 ms 0 KB -