Home>
AtCoder's Submit this code for this C issue However, there are two test cases for WA.
Because the official explanation and my assumed logic are a little different, it may be mistaken for the fundamental part.
My thoughts are described in comments in the source code.
Please tell me what is wrong in the code, and in what case is the error.
Thank you.
n = int (input ())
a = list (map (int, input (). split ()))
a.insert (0,0)
# Compare adjacent squares starting from the left side of the square.
# If there is a cell higher than the adjacent right cell, reduce the height by one.
for i in range (n):
if a [i]>a [i + 1]:
a [i]= 1
# Compare adjacent squares again.
# If there is a cell higher than the adjacent right cell, "No" is displayed.
for i in range (n):
if a [i]>a [i + 1]:
print ("No")
exit ()
print ("Yes")

Answer # 1

Answer # 2
That is a lie greed.
if a [i]>a [i1]: a [i]= 1
Is correct.
Related articles
 i want to run a macro from python, but for some reason i can't
 python  about the reason why the notation of the sample of the decision tree visualized by graphviz changes depending on the pr
 python 3x  "colorful leaderboard" atcoder abc064 code counterexample
 python  is the indentation wrong?
 python  there is something wrong with the current code and i want to improve it and get the specified output
 python  i don't know what's wrong with an error in serialize on the django rest framework
 python 3x  "friends" atcoder abc177 code counterexample question (union find)
 python  "atcoder abc 015d takahashikun's anguish" question about how to make a dp table for dynamic programming
 about for syntax i want to know the reason why the result is different depending on where the initial value is defined python
 i don't understand the reason for syntaxerror when executing python code
 python  atcoder bug not found [abc083b: some sums]
 python  please tell me the reason for using * in the print function other than the calculation formula
 python  decisiontreeclassifiers cannot be used for some reason
 c ++  atcoder abc112c it becomes wa for some reason
 python 3x  "rgb triplets" atcoder abc162 inquiry about computational complexity
 python 3x  i don't know why the answer to the function problem is
 c ++  atcoder abc086 c please tell me what is wrong
 c ++  atcoder abc140 b the answer is correct in my environment, but the submitted result is re
Trends
1,2,2,1
In this case, the answer is "Yes" because there are two 2's.
However, if this logic is applied to this case (hereinafter referred to as the first and second from the left)
The second is not larger than the third, so it is left as it is, and the third is larger than the fourth, so it falls by one.
As a result, the data is 1,2,1,1 and the result is No because it is not monotonously nondecreasing.