23402023-01-10 15:47:10sztomiDNScpp11Wrong answer 38/409ms6208 KiB
#include <bits/stdc++.h>

using namespace std;

bool lehet(vector<int>& indexek, int m){
    for(int i = 0; i <= indexek.size()-m; i++){
        if(indexek[i+m-1] - indexek[i] + 1 <= 2*m){
            return true;
        }
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    map<char, vector<int>> hely;
    string betuk = "ACGT";
    for(auto x : betuk){
        hely[x] = vector<int>();
    }
    for(int i = 0; i < s.size(); i++){
        hely[s[i]].push_back(i);
    }

    int mo = 1;
    int l, r, m, temp;
    int egyik, masik;
    for(auto betu : hely){
        l = 1;
        r = betu.second.size();
        temp = -1;
        while(l <= r){
            m = (l+r) / 2;
            if(lehet(betu.second, m)){
                temp = m;
                l = m+1;
            }
            else{
                r = m-1;
            }
        }
        //cout << "sikerult: " << betu.first << " " << temp*2 << "\n";
        mo = max(mo, temp*2);
    }

    cout << min(mo, (int)s.size()) << "\n";
}
SubtaskSumTestVerdictTimeMemory
base38/40
1Accepted0/03ms1828 KiB
2Wrong answer0/09ms5504 KiB
3Accepted2/22ms2292 KiB
4Accepted2/22ms2496 KiB
5Accepted2/22ms2700 KiB
6Accepted2/22ms2784 KiB
7Wrong answer0/22ms2916 KiB
8Accepted4/43ms4124 KiB
9Accepted4/44ms4316 KiB
10Accepted4/44ms4524 KiB
11Accepted4/44ms5360 KiB
12Accepted4/46ms5600 KiB
13Accepted5/56ms5932 KiB
14Accepted5/56ms6208 KiB