1 #include <iostream> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <vector> 5 #include <algorithm> 6 7 using namespace std; 8 bool CmpInt_1(int a,int b) 9 { 10 return a<b; 11 } 12 13 int main() 14 { 15 int n; 16 int i; 17 cin >> n; 18 19 vector<int> ATtotal(n+10,0); 20 int ATtotal_end = 0; 21 int tmp_cnt = 0; 22 int ATnum = 0; 23 int CGnum = 0; 24 char tmp_inputchar; 25 for(i = 0;i < n;i ++) 26 { 27 cin >> tmp_inputchar; 28 29 if(tmp_inputchar=='A'||tmp_inputchar=='T') 30 { 31 tmp_cnt ++; 32 ATnum ++; 33 } 34 else if(tmp_inputchar=='C'||tmp_inputchar=='G') 35 { 36 ATtotal[ATtotal_end++] = tmp_cnt; 37 tmp_cnt = 0; 38 CGnum ++; 39 } 40 } 41 42 ATtotal[ATtotal_end++] = tmp_cnt; 43 sort(ATtotal.begin(),ATtotal.end(),CmpInt_1); 44 45 int result = 0; 46 for(i = ATtotal.size()-1; i >=0; i --) 47 { 48 if(CGnum>=ATnum) 49 { 50 break; 51 } 52 else 53 { 54 CGnum += ATtotal[i]; 55 ATnum -= ATtotal[i]; 56 result ++; 57 } 58 } 59 cout << result << endl; 60 61 return 0; 62 }