Submission #69784

# Submission time Handle Problem Language Result Execution time Memory
69784 2018-08-21T13:32:13 Z Kubalionzzale Roller Coaster Railroad (IOI16_railroad) C++14
30 / 100
489 ms 88188 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> 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));
    int val = *set.begin();

    if (val > a[i].first)
      return 1;

    set.erase(set.begin());
    if (flag)
      set.insert(a[i].second);
  }

  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB n = 2
2 Correct 2 ms 488 KB n = 2
3 Correct 3 ms 488 KB n = 2
4 Correct 3 ms 488 KB n = 2
5 Correct 4 ms 656 KB n = 2
6 Incorrect 3 ms 656 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 376 KB n = 2
2 Correct 2 ms 488 KB n = 2
3 Correct 3 ms 488 KB n = 2
4 Correct 3 ms 488 KB n = 2
5 Correct 4 ms 656 KB n = 2
6 Incorrect 3 ms 656 KB answer is not correct: 1 instead of 523688153
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 489 ms 18520 KB n = 199999
2 Correct 327 ms 22364 KB n = 199991
3 Correct 283 ms 26212 KB n = 199993
4 Correct 371 ms 26212 KB n = 152076
5 Correct 164 ms 26212 KB n = 93249
6 Correct 324 ms 33536 KB n = 199910
7 Correct 372 ms 36680 KB n = 199999
8 Correct 395 ms 39496 KB n = 199997
9 Correct 403 ms 40588 KB n = 171294
10 Correct 292 ms 41048 KB n = 140872
11 Correct 390 ms 48144 KB n = 199886
12 Correct 264 ms 51216 KB n = 199996
13 Correct 273 ms 54132 KB n = 200000
14 Correct 284 ms 57364 KB n = 199998
15 Correct 332 ms 60192 KB n = 200000
16 Correct 316 ms 63800 KB n = 199998
17 Correct 328 ms 67512 KB n = 200000
18 Correct 353 ms 70492 KB n = 190000
19 Correct 264 ms 73004 KB n = 177777
20 Correct 170 ms 73004 KB n = 100000
21 Correct 452 ms 80444 KB n = 200000
22 Correct 354 ms 84324 KB n = 200000
23 Correct 446 ms 88188 KB n = 200000
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB n = 2
2 Correct 2 ms 488 KB n = 2
3 Correct 3 ms 488 KB n = 2
4 Correct 3 ms 488 KB n = 2
5 Correct 4 ms 656 KB n = 2
6 Incorrect 3 ms 656 KB answer is not correct: 1 instead of 523688153
7 Halted 0 ms 0 KB -