All submissions for this problem are available.
Given an array with
N(1 <= N <= 10000) integers, your task is to check if it could become non-decreasing by modifying at most
We define an array is non-decreasing if
array[i] <= array[i + 1] holds for every
i (1 <= i < N).
T N1 A B C D E ... N2 A B C D E ... N3 A B C D E ... ...
Tis the number of Arrays to be checked,
N3, etc. are the Number of Elements in each Array, and
E, etc. are the subsequent elements of that array.
Each new line is an individual input, and can be read with subsequent
input()statements in Python (or any alternative command for other languages that reads from the Standard Input or
Hint: To manipulate the numbers on the same line as an array, split the text input obtained, through a
' '(single space), since all numbers are delimited with a space, with a function like
split()or an equivalent (depending on what language you use).
For each String received, immediately output the result to the
STDOUTor Standard Output (eg. using
print()in Python), each on a new line.
This implies that the input has
2 3 4 2 3 4 4 2 1 2
2arrays. The first one has a length
3with the Elements
[4, 2, 3]while the second one has a length
4with the Elements
[4, 2, 1, 2].
- For array
[4, 2, 3], we could modify the first 4 to 1 to get a non-decreasing array.
- For the array
[4, 2, 1, 2], we can't get a non-decreasing array by modify at most one element.
|Time Limit:||10 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, JS|
Fetching successful submissions