結果
問題 | No.1943 消えたAGCT(1) |
ユーザー |
|
提出日時 | 2022-05-20 22:06:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 589 bytes |
コンパイル時間 | 1,547 ms |
コンパイル使用メモリ | 171,332 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-20 08:17:02 |
合計ジャッジ時間 | 2,763 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin>>N; string S; cin>>S; int cntATGC=0; for(int i=0;i<N;i++){ if(S[i]=='A'||S[i]=='T'||S[i]=='G'||S[i]=='C'){ cntATGC+=1; } } int k=cntATGC; stack<char>dS; for(int i=0;i<cntATGC;i++){ dS.push(S[i]); } int ans=0; while(cntATGC){ if(dS.size()==cntATGC){ if(dS.top()=='A'||dS.top()=='T'||dS.top()=='G'||dS.top()=='C')--cntATGC; dS.pop(); ++ans; }else{ dS.push(S[k++]); } } cout<<ans<<'\n'; }