No.3745 Line Seats
タグ : / 解いたユーザー数 20
作問者 :
競プロするわりとねこ
/ テストしたAI :
Problem Statement
People are sitting in $N$ seats arranged in a row. The seats are numbered $1,2,3,\ldots,N$ from the left.
The seating situation is given as a string $S$ of length $N$.
If the $i$-th character of $S$ is #, the $i$-th seat is occupied, and if it is ., the $i$-th seat is empty.
Flerovi is currently in front of the leftmost seat.
Flerovi wants to sit as far away from people as possible.
Specifically, he sits in the empty seat whose distance to the nearest # is the largest. If there are multiple such seats, he sits in the one closest to his current position, that is, closest to the left end.
Output the number of the seat in which Flerovi sits. Under the constraints of this problem, Flerovi can always sit.
Constraints
- $2 \le N \le 10^5$
- $|S| = N$
- $S$ contains at least one each of
#and.
Input
$N$ $S$
Partial Score
This problem has partial scoring based on subtasks.
| Subtask | Score | Constraints |
|---|---|---|
| 部分点 | 20% (40 pts) | $N \le 10^4$ |
| 満点 | 80% (160 pts) | 追加の制約は無い。 |
Output
Output the answer, followed by a newline.
Sample
Sample 1
Input
5 ##...
Output
5
Seat 5 has the largest distance from the nearest person, so output 5.
Sample 2
Input
7 #..#..#
Output
2
All the empty seats have the same distance from the nearest person, so output 2, the one closest to the left end.
Sample 3
Input
10 ..#.....##
Output
6
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。