結果

問題 No.2894 Monotonic Intervals
ユーザー Today03
提出日時 2024-09-20 21:21:57
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 386 bytes
コンパイル時間 2,427 ms
コンパイル使用メモリ 242,800 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-20 21:22:01
合計ジャッジ時間 3,165 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9 + 10;
const ll INFL = 4e18;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;

    int ans = 0;
    int idx = 0;
    while (idx < N) {
        ans++;
        while (idx + 1 < N && S[idx] == S[idx + 1]) {
            idx++;
        }
        idx++;
    }

    cout << ans << endl;
}
0