#CCBCHHAI0000012. Điểm hợp lệ trong [0,10] (First Valid Score and Invalid Count)
Điểm hợp lệ trong [0,10] (First Valid Score and Invalid Count)
First Valid Score and Invalid Count
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
A system reads integer scores one by one. A score in the closed interval is valid, including both endpoints. Reading stops upon the first valid score. Print that score and the number of invalid scores read before it. The accepted read is not counted as invalid.
Input
Whitespace-separated integer scores. The final value is the first valid score; no additional values follow it.
Output
Print two integers separated by a space: the first valid score and the number of invalid reads preceding it.
Subtasks
- Subtask 1 (20%): At most 5 integers, each of absolute value at most 10.
- Subtask 2 (30%): At most 100 integers, each of absolute value at most 1000.
- Subtask 3 (50%): At most 100001 integers, each of absolute value at most 1000000.
Examples
Example 1
Input
-1 11 0
Output
0 2
Explanation
The first two values, -1 and 11, are invalid, raising the count to 2. Zero is a valid endpoint, so print 0 and 2.
Example 2
Input
10
Output
10 0
Explanation
Ten is valid at the upper endpoint. No invalid reads occur.