結果

問題 No.1943 消えたAGCT(1)
ユーザー take000take000
提出日時 2022-05-20 21:42:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 270 ms / 2,000 ms
コード長 787 bytes
コンパイル時間 2,140 ms
コンパイル使用メモリ 208,484 KB
実行使用メモリ 27,268 KB
最終ジャッジ日時 2023-10-20 12:09:22
合計ジャッジ時間 6,928 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 264 ms
27,268 KB
testcase_10 AC 164 ms
27,268 KB
testcase_11 AC 166 ms
27,268 KB
testcase_12 AC 243 ms
27,268 KB
testcase_13 AC 116 ms
17,788 KB
testcase_14 AC 6 ms
4,348 KB
testcase_15 AC 249 ms
25,708 KB
testcase_16 AC 194 ms
21,484 KB
testcase_17 AC 210 ms
22,540 KB
testcase_18 AC 270 ms
27,268 KB
testcase_19 AC 267 ms
27,268 KB
testcase_20 AC 265 ms
27,268 KB
testcase_21 AC 266 ms
27,268 KB
testcase_22 AC 266 ms
27,268 KB
testcase_23 AC 266 ms
27,268 KB
testcase_24 AC 164 ms
27,268 KB
testcase_25 AC 165 ms
27,268 KB
testcase_26 AC 165 ms
27,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);

    int N;
    string S;
    cin >> N >> S;

    int cnt = 0;
    string t = "AGCT";
    rep(i, N) rep(j, 4) {
        if (S[i] == t[j])
            cnt++;
    }

    set<int> st;
    rep(i, N) st.insert(i);

    int idx = cnt - 1, ans = 0;
    while (cnt != 0) {
        bool flag = false;
        rep(j, 4) {
            if (S[idx] == t[j]) {
                flag = true;
                break;
            }
        }

        if (flag) {
            cnt--;
        }
        st.erase(idx);
        idx = *st.lower_bound(cnt - 1);

        ans++;
    }
    cout << ans << "\n";

    return 0;
}
0