Submission #645742

# Submission time Handle Problem Language Result Execution time Memory
645742 2022-09-27T19:23:22 Z perohero medians (balkan11_medians) C++14
0 / 100
81 ms 12980 KB
#include <bits/stdc++.h>

using ll = long long;

int const nmax = 100000;

int a[1 + nmax], b[1 + 2 * nmax];
bool fr[1 + nmax];
std::set<int> s;

int main() {
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);

  int n;
  std::cin >> n;
  for(int i = 1;i <= n; i++) {
    std::cin >> a[i];
  }
  for(int i = 1;i <= 2 * n; i++)
    s.insert(i);
  b[1] = a[1];
  fr[1] = 1;
  s.erase(a[1]);
  for(int i = 2;i <= n; i++) {
    if(a[i - 1] < a[i]) {
      auto it = s.end();
      it--;
      b[2 * i - 1] = *it;
      s.erase(b[2 * i - 1]);
      if(fr[a[i]]) {
        it = s.end();
        it--;
        b[2 * i - 2] = *it;
      } else {
        b[2 * i - 2] = a[i];
      }
      s.erase(b[2 * i - 2]);
      fr[b[2 * i - 1]] = true;
      fr[b[2 * i - 2]] = true;
    } else if(a[i] == a[i - 1]) {
      auto it = s.end();
      it--;
      b[2 * i - 1] = *s.begin();
      b[2 * i - 2] = *it;
      s.erase(b[2 * i - 1]);
      s.erase(b[2 * i - 2]);
      fr[b[2 * i - 1]] = true;
      fr[b[2 * i - 2]] = true;
    } else {
      auto it = s.begin();
      b[2 * i - 1] = *it;
      it++;
      if(fr[a[i]])
        b[2 * i - 2] = *it;
      else
        b[2 * i - 2] = a[i];
      s.erase(b[2 * i - 1]);
      s.erase(b[2 * i - 2]);
      fr[b[2 * i - 1]] = 1;
      fr[b[2 * i - 2]] = 1;
    }
  }

  for(int i = 1;i <= 2 * n; i++)
    std::cout << b[i] << " ";
  return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 388 KB Integer 20 violates the range [1, 19]
2 Incorrect 1 ms 340 KB Integer 40 violates the range [1, 39]
3 Incorrect 1 ms 340 KB Integer 60 violates the range [1, 59]
4 Incorrect 0 ms 340 KB Integer 80 violates the range [1, 79]
5 Incorrect 0 ms 340 KB Integer 100 violates the range [1, 99]
6 Incorrect 0 ms 332 KB Extra information in the output file
7 Incorrect 1 ms 332 KB Integer 140 violates the range [1, 139]
8 Incorrect 1 ms 340 KB Integer 160 violates the range [1, 159]
9 Incorrect 1 ms 324 KB Integer 180 violates the range [1, 179]
10 Incorrect 1 ms 340 KB Integer 200 violates the range [1, 199]
11 Incorrect 1 ms 332 KB Integer 600 violates the range [1, 599]
12 Incorrect 1 ms 340 KB Integer 1200 violates the range [1, 1199]
13 Incorrect 1 ms 456 KB Integer 2000 violates the range [1, 1999]
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 468 KB Integer 4000 violates the range [1, 3999]
2 Incorrect 4 ms 724 KB Integer 8000 violates the range [1, 7999]
3 Incorrect 5 ms 1304 KB Integer 16000 violates the range [1, 15999]
4 Incorrect 11 ms 2260 KB Integer 32000 violates the range [1, 31999]
5 Incorrect 23 ms 4296 KB Integer 64000 violates the range [1, 63999]
6 Incorrect 50 ms 8304 KB Integer 16843009 violates the range [1, 127999]
7 Incorrect 81 ms 12980 KB Integer 16843009 violates the range [1, 199999]