Help me in solving ROCPAPSCI problem

My issue

i dont know where i m getting wrong . my approach is to count the chars which are not same consecutively and count the chars which are same and then add the counts of not same chars with the mod of same char counted and quotient of count of same chars

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    int n;
	    cin>>n;
	    string s;
	    cin>>s;
	    int count=1;
	    int ans=0;
	    for(int i=0;i<n-1;i++){
	        if(s[i]==s[i+1]){
	            count++;
	        }
	        else{
	            count=1;
	            ans++;
	        }
	    }
	    cout<<ans+(count%2)+(count/2)<<endl;
	}

}

Problem Link: Rock Paper Scissors Practice Coding Problem - CodeChef

@techno_132
plzz refer my c++ code for better understanding of the logic

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	   string s;
	   cin>>s;
	   int cnt=1;
	   int ans=0;
	   for(int i=1;i<n;i++)
	   {
	       if(s[i]==s[i-1])
	       {
	           cnt++;
	       }
	       else
	       {
	       ans+=(ceil(cnt*1.0/2.0));
	       cnt=1;
	       }
	   }
	   ans+=(ceil(cnt*1.0/2.0));
	   cout<<ans<<endl;
	}
	return 0;
}