14412022-10-10 13:53:36AbbenceDNScpp17Time limit exceeded 10/40374ms33100 KiB
#include <iostream>
#include <map>

using namespace std;

// nem sajat kod

int main()
{
    string dns;
    cin >> dns;
    map<int,int> kezd;
    map<int,int> veg;
    string betuk="ACGT";
    int maxh=0;
    int a;
    int mina;
    for(int i=0;i<4;i++)
    {
        kezd.clear();
        kezd[0]=0;
        veg.clear();
        veg[0]=0;
        a=0;
        mina=0;
        for(int j=0;j<dns.length();j++)
        {
            if(dns[j]==betuk[i])
            {
                a++;
            }
            else
            {
                a--;
                if(mina>a) mina=a;
            }
            for(int k=a;k>=mina;k--)
            {
                if(kezd.find(k)==kezd.end()) kezd[k]=j+1;
                veg[k]=j+1;
                maxh=max(maxh,veg[k]-kezd[k]);
            }
        }
    }
    cout << maxh;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base10/40
1Accepted0/03ms1936 KiB
2Time limit exceeded0/0370ms13756 KiB
3Accepted2/22ms2600 KiB
4Accepted2/22ms2836 KiB
5Accepted2/22ms2952 KiB
6Accepted2/23ms3120 KiB
7Accepted2/23ms3452 KiB
8Time limit exceeded0/4370ms3000 KiB
9Time limit exceeded0/4374ms8236 KiB
10Time limit exceeded0/4365ms9036 KiB
11Time limit exceeded0/4370ms11472 KiB
12Time limit exceeded0/4351ms33100 KiB
13Time limit exceeded0/5363ms21184 KiB
14Time limit exceeded0/5368ms23448 KiB