답안 #69794

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
69794 2018-08-21T13:43:02 Z Kubalionzzale Roller Coaster Railroad (IOI16_railroad) C++14
30 / 100
513 ms 14848 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);
  }
  
  long long int ans = 0;

  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();
    ans += std::max(0LL, val - a[i].first * 1LL);

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

  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB n = 2
2 Correct 3 ms 476 KB n = 2
3 Correct 3 ms 512 KB n = 2
4 Correct 3 ms 512 KB n = 2
5 Correct 2 ms 512 KB n = 2
6 Correct 2 ms 524 KB n = 2
7 Correct 2 ms 568 KB n = 3
8 Correct 2 ms 572 KB n = 3
9 Correct 2 ms 716 KB n = 3
10 Correct 2 ms 716 KB n = 8
11 Incorrect 2 ms 716 KB answer is not correct: 212715093 instead of 189002015
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB n = 2
2 Correct 3 ms 476 KB n = 2
3 Correct 3 ms 512 KB n = 2
4 Correct 3 ms 512 KB n = 2
5 Correct 2 ms 512 KB n = 2
6 Correct 2 ms 524 KB n = 2
7 Correct 2 ms 568 KB n = 3
8 Correct 2 ms 572 KB n = 3
9 Correct 2 ms 716 KB n = 3
10 Correct 2 ms 716 KB n = 8
11 Incorrect 2 ms 716 KB answer is not correct: 212715093 instead of 189002015
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 404 ms 14712 KB n = 199999
2 Correct 502 ms 14712 KB n = 199991
3 Correct 443 ms 14840 KB n = 199993
4 Correct 349 ms 14840 KB n = 152076
5 Correct 155 ms 14840 KB n = 93249
6 Correct 332 ms 14840 KB n = 199910
7 Correct 337 ms 14840 KB n = 199999
8 Correct 337 ms 14840 KB n = 199997
9 Correct 412 ms 14840 KB n = 171294
10 Correct 319 ms 14840 KB n = 140872
11 Correct 336 ms 14840 KB n = 199886
12 Correct 353 ms 14840 KB n = 199996
13 Correct 329 ms 14840 KB n = 200000
14 Correct 326 ms 14840 KB n = 199998
15 Correct 310 ms 14840 KB n = 200000
16 Correct 305 ms 14848 KB n = 199998
17 Correct 315 ms 14848 KB n = 200000
18 Correct 397 ms 14848 KB n = 190000
19 Correct 274 ms 14848 KB n = 177777
20 Correct 190 ms 14848 KB n = 100000
21 Correct 457 ms 14848 KB n = 200000
22 Correct 451 ms 14848 KB n = 200000
23 Correct 513 ms 14848 KB n = 200000
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB n = 2
2 Correct 3 ms 476 KB n = 2
3 Correct 3 ms 512 KB n = 2
4 Correct 3 ms 512 KB n = 2
5 Correct 2 ms 512 KB n = 2
6 Correct 2 ms 524 KB n = 2
7 Correct 2 ms 568 KB n = 3
8 Correct 2 ms 572 KB n = 3
9 Correct 2 ms 716 KB n = 3
10 Correct 2 ms 716 KB n = 8
11 Incorrect 2 ms 716 KB answer is not correct: 212715093 instead of 189002015
12 Halted 0 ms 0 KB -