Nearest Taller

AtCoder
IDabc433_b
Time2000ms
Memory256MB
Difficulty
There are $N$ people standing in a row from left to right. The $i$\-th person from the left $(1\le i\le N)$ is called person $i$. The height of person $i$ $(1\le i\le N)$ is $A_i$. For each $i=1,2,\ldots,N$, determine whether there exists a person to the left of person $i$ who is taller than person $i$, and if so, find the person standing closest to person $i$ among them. ## Constraints * $1\le N\le 100$ * $1\le A_i\le 100$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ $A_1$ $A_2$ $\ldots$ $A_N$ [samples]
Samples
Input #1
4
4 3 2 5
Output #1
\-1
1
2
-1

*   There is no person to the left of person $1$. Thus, output $-1$ on the first line.
*   Among the people to the left of person $2$, only person $1$ is taller than person $2$. Thus, output $1$ on the second line.
*   Among the people to the left of person $3$, persons $1,2$ are taller than person $3$, and the person standing closest to person $3$ is person $2$. Thus, output $2$ on the third line.
*   There is no person to the left of person $4$ who is taller than person $4$. Thus, output $-1$ on the fourth line.
Input #2
3
7 7 7
Output #2
\-1
-1
-1

There may be multiple people with the same height.
Input #3
6
31 9 17 10 2 9
Output #3
\-1
1
1
3
4
4
API Response (JSON)
{
  "problem": {
    "name": "Nearest Taller",
    "description": {
      "content": "There are $N$ people standing in a row from left to right. The $i$\\-th person from the left $(1\\le i\\le N)$ is called person $i$. The height of person $i$ $(1\\le i\\le N)$ is $A_i$. For each $i=1,2,\\ld",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc433_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "There are $N$ people standing in a row from left to right. The $i$\\-th person from the left $(1\\le i\\le N)$ is called person $i$. The height of person $i$ $(1\\le i\\le N)$ is $A_i$.\nFor each $i=1,2,\\ld...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments