Stones

AtCoder
IDtenka1_2019_c
Time2000ms
Memory256MB
Difficulty
There are $N$ stones arranged in a row. Every stone is painted white or black. A string $S$ represents the color of the stones. The $i$\-th stone from the left is white if the $i$\-th character of $S$ is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored. ## Constraints * $1 \leq N \leq 2\times 10^5$ * $S$ is a string of length $N$ consisting of `.` and `#`. ## Input Input is given from Standard Input in the following format: $N$ $S$ [samples]
Samples
Input #1
3
#.#
Output #1
1

It is enough to change the color of the first stone to white.
Input #2
5
#.##.
Output #2
2
Input #3
9
.........
Output #3
0
API Response (JSON)
{
  "problem": {
    "name": "Stones",
    "description": {
      "content": "There are $N$ stones arranged in a row. Every stone is painted white or black. A string $S$ represents the color of the stones. The $i$\\-th stone from the left is white if the $i$\\-th character of $S$",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "tenka1_2019_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "There are $N$ stones arranged in a row. Every stone is painted white or black. A string $S$ represents the color of the stones. The $i$\\-th stone from the left is white if the $i$\\-th character of $S$...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments