#P10077. [GDKOI2024 普及组] 读书
[GDKOI2024 普及组] 读书
Problem Description
Zayin is a student who loves reading.
Recently, Zayin received a book with chapters. Each chapter has a requirement: she must have read at least other chapters before she can gain enough wisdom to understand that chapter.
Every day, Zayin starts reading the book from the beginning to the end. For chapters that she still cannot understand (due to the requirement) or chapters that she has already read, Zayin will skip them on that day.
Now, Zayin wants to know the minimum number of days needed to finish reading all chapters.
Input Format
The first line contains two integers , representing the test point ID and the number of chapters.
The second line contains integers , representing the requirements.
Output Format
Output one line containing one integer, representing the minimum number of days needed.
If Zayin cannot finish reading all chapters, output .
1 10
3 4 0 6 1 1 0 8 6 3
2
Hint
This problem uses bundled subtasks.
For all testdata, it is guaranteed that , .
- Subtask 1 (10%): , .
- Subtask 2 (10%): , .
- Subtask 3 (20%): , .
- Subtask 4 (20%): , .
- Subtask 5 (40%): , .
Translated by ChatGPT 5