結果

問題 No.2035 Tunnel
ユーザー rogi52
提出日時 2022-08-12 22:23:10
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 609 bytes
コンパイル時間 2,140 ms
コンパイル使用メモリ 196,968 KB
最終ジャッジ日時 2025-01-30 21:16:52
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 4 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    int N; string S; cin >> N >> S;
    int L = 0;
    while(S[L] != '#') L++;
    vector<pair<char,ll>> v;
    v.push_back({S[0], 1});
    for(int i = 1; i < N; i++) {
        if(v.back().first == S[i]) {
            v.back().second++;
        } else {
            v.push_back({S[i], 1});
        }
    }

    ll ans = 0;
    for(auto [ch, cnt] : v) if(ch == '#') ans = max(ans, cnt * (cnt - 1) / 2);
    cout << ans + N - L << endl;
}
0