There are
It is guaranteed that every student begins at a different chair.
Edit: The test data has been fixed.
Constraints
For all subtasks:
All the indices in the input will be between
Subtask 1 [30%]
Subtask 2 [50%]
Subtask 3 [20%]
Input Specification
The first line will have two space-separated integers,
The next line will have
The third line will have
Output Specification
Output a single integer, the index of the last standing student.
Sample Input
7 2
2 1
6 5 4
Sample Output
3
Comments
Okay. Thanks wleung_bvg very much!
Will that happen?
What should I output if more than one students remain standing in the end and sit down at the same time? Will that happen?
Since there is exactly 1 less chair than students, if the last 2 students were to sit down at the same time, then they must be sitting down at the same chair. Since each student only move forward exactly one spot each second, then for this to happen, they would have had to start at the same place. Since the problem guarantees that each student starts at a different location, we know that this situation is impossible.
What if the input is:
4 2
2 4
1 2 3?
2nd student will immediately sit down. After one round, 1 sit on 2 and 3 sit on 4.
For clarification, if a student sit on a chair, will that chair count as non-empty?
Student 1 cannot sit on chair 2 since student 2 is already sitting there.