結果

問題 No.1943 消えたAGCT(1)
ユーザー koryoukoryou
提出日時 2022-05-20 22:06:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 216 ms / 2,000 ms
コード長 2,148 bytes
コンパイル時間 990 ms
コンパイル使用メモリ 110,116 KB
実行使用メモリ 27,288 KB
最終ジャッジ日時 2023-10-20 12:47:29
合計ジャッジ時間 3,031 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 216 ms
27,288 KB
testcase_10 AC 13 ms
4,348 KB
testcase_11 AC 13 ms
4,348 KB
testcase_12 AC 13 ms
4,348 KB
testcase_13 AC 9 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 37 ms
7,248 KB
testcase_16 AC 29 ms
6,456 KB
testcase_17 AC 31 ms
6,516 KB
testcase_18 AC 40 ms
7,488 KB
testcase_19 AC 40 ms
7,488 KB
testcase_20 AC 40 ms
7,488 KB
testcase_21 AC 40 ms
7,488 KB
testcase_22 AC 148 ms
19,368 KB
testcase_23 AC 147 ms
19,368 KB
testcase_24 AC 15 ms
4,348 KB
testcase_25 AC 15 ms
4,348 KB
testcase_26 AC 15 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <list>
#include <cassert>
#include <numeric>
#include <cstdint>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <random>
#include <bitset>
// #include <atcoder/all>
 
using ll = long long;
using ld = long double;
using namespace std;
// using namespace atcoder;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
using Priority = priority_queue<ll, vector<ll>, greater<ll>>;// 昇順
using Priority_pair = priority_queue<P, vector<P>, greater<P>>;
// using mint_17 = modint1000000007;
// using mint = modint998244353;

#define mod 1000000007
#define MAX_WIDTH 60
#define MAX_HEIGHT 60
#define INF 1e18
#define MOD 998244353
#define PI 3.141592653589793
#define rep(i, a, b) for(ll i=(a);i<(b);i++)
#define rrep(i, a, b) for(ll i=(a);i>=(b);i--)
#define fore(i, a) for(auto &i: a)
#define all(v) (v).begin(), (v).end()
#define YES(a) cout << ((a) ? "YES" : "NO") << endl
#define Yes(a) cout << ((a) ? "Yes" : "No") << endl
#define pb(a) push_back(a)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vp vector<pair<ll, ll>>
#define mll map<ll, ll>
#define msl map<string, ll>
#define COUT(n) cout << (n) << endl
#define isInGrid(n, h, w) (0 <= (n) && (n) < (h) && 0 <= (n) && (n) < (w))
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int vx[] = {1,0,-1,0}, vy[] = {0,1,0,-1};

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

    ll C = 0;
    set<ll> s;
    rep(i, 0, N) {
        if(S[i] == 'A' || S[i] == 'G' || S[i] == 'C' || S[i] == 'T') {
            C++;
            s.insert(i);
        }
    }

    ll ans = 0, d = 0;
    C--;
    while(C >= 0) {
        auto ite = s.lower_bound(C);
        ll len = (*ite)-C+1;
        if(*ite != C) len -= d;
        d += len;
        ans += len;
        s.erase(ite);
        C--;
    }
    COUT(ans);

    return 0;
}
0