結果
| 問題 | No.3745 Line Seats |
| ユーザー |
👑 |
| 提出日時 | 2026-09-23 13:32:24 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 2 ms / 2,000 ms |
| + 720µs | |
| コード長 | 982 bytes |
| 記録 | |
| コンパイル時間 | 2,151 ms |
| コンパイル使用メモリ | 353,888 KB |
| 実行使用メモリ | 9,904 KB |
| 最終ジャッジ日時 | 2026-09-23 13:32:30 |
| 合計ジャッジ時間 | 4,512 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge4_0 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| 部分点 | 20 % | AC * 47 |
| 満点 | 80 % | AC * 60 |
| 合計 | 2 * 100% = 200 点 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int INF = 1e8;
template <typename T>
bool chmax(T &a, const T& b) {
if (a < b) {
a = b; // aをbで更新
return true;
}
return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
if (a > b) {
a = b; // aをbで更新
return true;
}
return false;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N; string S;
cin >> N >> S;
vector<int> distances(N, INF);
int prev = -INF;
for (int i = 0; i < N; i++) {
if (S[i] == '#') prev = i;
chmin(distances[i], i - prev);
}
prev = INF;
for (int i = N - 1; i >= 0; i--) {
if (S[i] == '#') prev = i;
chmin(distances[i], prev - i);
}
int answer = -INF;
int max_dist = 0;
for (int i = 0; i < N; i++) {
if (chmax(max_dist, distances[i])) {
answer = i + 1;
}
}
cout << answer << '\n';
}