Universal Cup Judging System

Universal Cup

시간 제한: 2.0 s 메모리 제한: 1024 MB 총점: 100 해킹 가능 ✓
통계

תיאור

נתונים שני מספרים שלמים $N$ ו-$X$, וסדרת מספרים שלמים $A = (A_1, A_2, \dots, A_N)$ באורך $N$. עליכם לבנות סדרת מספרים שלמים $s = (s_1, s_2, \dots, s_N)$ באורך $N$ המקיימת את כל התנאים הבאים:

  • $1 \le s_i \le X$
  • $s_i \neq A_i$ ($1 \le i \le N$)

מצאו את המספר המרבי האפשרי של אינדקסים $i$ ($1 \le i < N$) עבורם מתקיים $s_i = s_{i+1}$.

קלט

הקלט ניתן בפורמט הבא:

N X
A_1 A_2 ... A_N
  • $1 \le N \le 5 \times 10^5$
  • $2 \le X \le 10^9$
  • $1 \le A_i \le X$ ($1 \le i \le N$)
  • כל ערכי הקלט הם מספרים שלמים.

פלט

הדפיסו את התשובה.

דוגמאות

קלט 1

8 3
1 2 2 3 2 1 2 1

פלט 1

5

קלט 2

4 8
7 6 3 8

פלט 2

3

הערה

במקרה הבדיקה הראשון, לדוגמה, אם נבחר $s = (3, 3, 1, 1, 3, 3, 3, 3)$, אז האינדקסים $i$ המקיימים $s_i = s_{i+1}$ הם $1, 3, 5, 6, 7$, ובסך הכול $5$. ניתן להראות שאי אפשר לגרום לכך ש-$s_i = s_{i+1}$ יתקיים עבור יותר אינדקסים מאלה, ולכן התשובה היא $5$.

במקרה הבדיקה השני, לדוגמה, נוכל לבחור $s = (5, 5, 5, 5)$.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1486EditorialOpen题解jianglyView
#1344EditorialOpen题解MilmonView

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.