Universal Cup Judging System

Universal Cup

Süre Sınırı: 2.0 s Bellek Sınırı: 1024 MB Toplam puan: 100 Hack'lenebilir ✓
İstatistikler

Dane są dwa ciągi $A$ oraz $B$ o długości $N$.

Rozstrzygnij, czy istnieje permutacja $C$ zbioru $(1, 2, \dots, N)$ taka, że dla wszystkich $i$ ($1 \le i \le N$) długość LIS (najdłuższego podciągu rosnącego) prefiksu o długości $i$ wynosi $A_i$, a długość LDS (najdłuższego podciągu malejącego) prefiksu o długości $i$ wynosi $B_i$.

Jeśli taka permutacja istnieje, skonstruuj jedną z nich.

Wejście

Wejście jest podane w następującym formacie:

$$N$$ $$A_1\ A_2\ \dots\ A_N$$ $$B_1\ B_2\ \dots\ B_N$$

Ograniczenia

  • $1 \le N \le 5 \times 10^5$
  • $1 \le A_i \le N$ ($1 \le i \le N$)
  • $1 \le B_i \le N$ ($1 \le i \le N$)
  • Wszystkie wartości wejściowe są liczbami całkowitymi.

Wyjście

Jeśli taka permutacja nie istnieje, wypisz $-1$. W przeciwnym razie wypisz $N$ oddzielonych spacjami liczb całkowitych reprezentujących elementy permutacji $C$. Jeśli istnieje wiele takich permutacji, dowolna z nich zostanie zaakceptowana.

Przykłady

Wejście 1

3
1 1 2
1 2 2

Wyjście 1

2 1 3

Wejście 2

4
1 1 2 2
1 2 2 3

Wyjście 2

3 2 4 1

Wejście 3

4
1 2 2 3
1 2 2 2

Wyjście 3

-1

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#2544EditorialOpen题解KobicGendView
#1488EditorialOpen题解jianglyView

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.