結果

問題 No.2035 Tunnel
ユーザー maclemacle
提出日時 2022-08-12 21:41:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 1,808 bytes
コンパイル時間 1,644 ms
コンパイル使用メモリ 169,096 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 08:58:38
合計ジャッジ時間 2,711 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 9 ms
4,348 KB
testcase_06 AC 9 ms
4,348 KB
testcase_07 AC 9 ms
4,348 KB
testcase_08 AC 8 ms
4,348 KB
testcase_09 AC 9 ms
4,348 KB
testcase_10 AC 9 ms
4,348 KB
testcase_11 AC 8 ms
4,348 KB
testcase_12 AC 10 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 4 ms
4,348 KB
testcase_15 AC 9 ms
4,348 KB
testcase_16 AC 7 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 AC 5 ms
4,348 KB
testcase_20 AC 8 ms
4,348 KB
testcase_21 AC 5 ms
4,348 KB
testcase_22 AC 4 ms
4,348 KB
testcase_23 AC 3 ms
4,348 KB
testcase_24 AC 5 ms
4,348 KB
testcase_25 AC 6 ms
4,348 KB
testcase_26 AC 6 ms
4,348 KB
testcase_27 AC 8 ms
4,348 KB
testcase_28 AC 5 ms
4,348 KB
testcase_29 AC 3 ms
4,348 KB
testcase_30 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;

const long long mod = 1e9 + 7;
// const long long mod = 998244353;
const double PI = acos(-1);
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define rep(i,a,b) for(int i=(a);i<(b);i++)

// begin() end()
#define all(x) (x).begin(),(x).end()

//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(12) << x << endl
#define printc(x) cout << setw(6) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

//最大公約数 
 ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
	return a / gcd(a, b) * b; 
}
const int INF = 1000000000;
const double DINF = 1LL<<60;
const long long LINF = 1LL<<60;
const int MAX = 510000;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// Nは問題によって変更すること
// vector<int>ind(N);
// REP(i, N) ind[i]= i;
//sort(all(ind), [&](int i, int j) {return x[i] < x[j];});


ll dy[4] = {0, 1, 0, -1}, dx[4] = {1, 0, -1, 0};
// ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1}, dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};


vector<vector<int>>G;


int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	ll ans = 0;
	ll cnt = 0;
	rrep(i, N - 1, -1){
		if(S[i] != '#'){
			cnt = max(0LL, cnt - 1);
			continue;
		}
		chmax(ans, (N - i) + cnt);
		cnt++;
	}

	cout << ans << endl;
	

	return 0;
}
0