問題一覧 > 通常問題

No.3745 Line Seats

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 20
作問者 : Nihonielse / テスター : 競プロするわりとねこ / テストしたAI : gemini-3.5-flash-lite
お気に入りにしたユーザー ProblemId : 13936 / 自分の提出
問題文最終更新日: 2026-09-23 13:56:06
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original

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.

SubtaskScoreConstraints
部分点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もしくは右上の雲マークをクリックしてアカウントを作成してください。