結果

問題 No.1951 消えたAGCT(2)
ユーザー 沙耶花沙耶花
提出日時 2022-05-20 22:09:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 960 bytes
コンパイル時間 4,351 ms
コンパイル使用メモリ 264,404 KB
実行使用メモリ 5,944 KB
最終ジャッジ日時 2023-10-20 12:50:22
合計ジャッジ時間 7,658 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 2 ms
4,368 KB
testcase_04 AC 2 ms
4,368 KB
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 2 ms
4,368 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 WA -
testcase_09 AC 24 ms
5,928 KB
testcase_10 AC 24 ms
5,928 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 151 ms
5,424 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 23 ms
5,928 KB
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001

char get(char c,int a){
	a += 26;
	a %= 26;
	rep(i,a){
		c++;
		if(c>'Z')c = 'A';
	}
	return c;
}

int main() {
    
	int n;
	cin>>n;
	string s;
	cin>>s;
	
	fenwick_tree<int> F(n);
	rep(i,n)F.add(i,1);
	
	vector<int> c(26);
	rep(i,n){
		c[s[i]-'A']++;
	}
	
	int add = 0;
	
	while(true){
		int c0 = 0;
		c0 += c[get('A',-add)-'A'];
		c0 += c[get('G',-add)-'A'];
		c0 += c[get('C',-add)-'A'];
		c0 += c[get('T',-add)-'A'];
		if(c0==0)break;
		int ok = 0,ng = n;
		while(ng-ok>1){
			int mid = (ok+ng)/2;
			if(F.sum(0,mid)<c0)ok = mid;
			else ng = mid;
		}
		add += c[s[ok]-'A']-1;
		c[s[ok]-'A']--;
		s[ok] = '-';
		F.add(ok,-1);
	}
	int ans = 0;
	rep(i,s.size()){
		if(s[i]!='-'){
			//ans += get(s[i],add);
		}
		else ans++;
	}
	cout<<ans<<endl;
	
    return 0;
}
0