Submission #69135

# Submission time Handle Problem Language Result Execution time Memory
69135 2018-08-20T05:56:44 Z Kubalionzzale Roller Coaster Railroad (IOI16_railroad) C++14
0 / 100
533 ms 23828 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 3 ms 376 KB n = 2
2 Correct 3 ms 488 KB n = 2
3 Correct 2 ms 564 KB n = 2
4 Correct 3 ms 564 KB n = 2
5 Correct 3 ms 564 KB n = 2
6 Incorrect 2 ms 564 KB answer is not correct: 1 instead of 523688153
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB n = 2
2 Correct 3 ms 488 KB n = 2
3 Correct 2 ms 564 KB n = 2
4 Correct 3 ms 564 KB n = 2
5 Correct 3 ms 564 KB n = 2
6 Incorrect 2 ms 564 KB answer is not correct: 1 instead of 523688153
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 478 ms 14648 KB n = 199999
2 Correct 533 ms 14648 KB n = 199991
3 Correct 466 ms 17548 KB n = 199993
4 Correct 400 ms 17548 KB n = 152076
5 Correct 197 ms 17548 KB n = 93249
6 Correct 378 ms 21692 KB n = 199910
7 Incorrect 408 ms 23828 KB answer is not correct: 1 instead of 0
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB n = 2
2 Correct 3 ms 488 KB n = 2
3 Correct 2 ms 564 KB n = 2
4 Correct 3 ms 564 KB n = 2
5 Correct 3 ms 564 KB n = 2
6 Incorrect 2 ms 564 KB answer is not correct: 1 instead of 523688153
7 Halted 0 ms 0 KB -