Submission #49041831


Source Code Expand

#include <iostream>

using namespace std;
using ui = unsigned int;

int main()
{
  ui n;
  cin >> n;

  int prev = 0;
  for (ui i = 0; i < n; i++)
  {
    int a;
    cin >> a;

    if (prev == 0 || abs(a - prev) == 1)
    {
      if (i > 0)
      {
        cout << " ";
      }
      cout << a;
      prev = a;
      continue;
    }

    if (a > prev)
    {
      for (int aa = prev + 1; aa <= a; aa++)
      {
        cout << " " << aa;
      }
    }
    else
    {
      for (int aa = prev - 1; aa >= a; aa--)
      {
        cout << " " << aa;
      }
    }

    prev = a;
  }

  cout << endl;

  return 0;
}

Submission Info

Submission Time
Task B - Fill the Gaps
User michimani
Language C++ 20 (Clang 16.0.6)
Score 200
Code Size 659 Byte
Status AC
Exec Time 2 ms
Memory 3604 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 10
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
random_01.txt AC 2 ms 3480 KiB
random_02.txt AC 1 ms 3604 KiB
random_03.txt AC 2 ms 3456 KiB
random_04.txt AC 1 ms 3488 KiB
random_05.txt AC 1 ms 3488 KiB
random_06.txt AC 2 ms 3488 KiB
random_07.txt AC 1 ms 3512 KiB
random_08.txt AC 1 ms 3436 KiB
sample_01.txt AC 1 ms 3388 KiB
sample_02.txt AC 1 ms 3516 KiB