結果
| 問題 | No.2035 Tunnel |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2022-08-16 02:35:52 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 581 bytes |
| 記録 | |
| コンパイル時間 | 361 ms |
| コンパイル使用メモリ | 52,688 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-06-27 01:48:22 |
| 合計ジャッジ時間 | 3,727 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2035.cc: No.2035 Tunnel - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 300000;
const int INF = 1 << 30;
/* typedef */
/* global variables */
char s[MAX_N + 4];
int xs[MAX_N], dp[MAX_N + 1];
/* subroutines */
/* main */
int main() {
int n;
scanf("%d%s", &n, s);
int m = 0;
for (int i = 0; i < n; i++)
if (s[i] == '#') xs[m++] = i;
dp[m] = -INF;
for (int i = m - 1; i >= 0; i--)
dp[i] = max(dp[i + 1] + 2, n - xs[i]);
printf("%d\n", dp[0]);
return 0;
}
tnakao0123