3 solutions

  • 0
    @ 2025-8-26 11:51:26
    
    #include <bits/stdc++.h>
    using namespace std;
    int n, cnt = 1, ans = 1;
    string s;
    int main()
    {
    	cin >> n >> s;
    	for (int i = 1;i < n;i++)
    	{
    		if (s[i] - s[i - 1] == 1)
    		{
    			cnt++;
    		}
    		else
    		{
    			ans = max (ans, cnt);
    			cnt = 1;
    		}
    	}
    	cout << ans;
    	return 0;
    }
    

    Information

    ID
    1031
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    8
    Tags
    # Submissions
    79
    Accepted
    14
    Uploaded By