Comments

Can someone tell error in my code is gives WA on 3rd test case

void solve() {
    int n, m;  
    cin >> n >> m;
    vi v(n);    input(v);
    vector<pair<int,string>> zeroes;
    int cnt = 0;

    for(int i =0; i < n ; ++i){    
        string s = to_string(v[i]);
            if(s[s.size()-1] != '0'){
                cnt += s.size();
                continue;
            }
        int ending_zeroes = 0;        
        for(int j = s.size()-1; j >= 0 && s[j] == '0' ; --j){
            ending_zeroes++;
        }
        pair<int,string>temp;
        temp.first = ending_zeroes;
        temp.second = s;
        zeroes.push_back(temp);
    }
    sort(all(zeroes), greater<pair<int,string>>());
    for(int i =0; i < zeroes.size() ; ++i){
        if(i % 2){
            cnt += zeroes[i].second.size();
        }else{
            string s = zeroes[i].second;
            for(int j = 0; j < s.size() && s[j] != '0' ; ++j ){
                cnt++;
            }
        }
    }
    if(cnt >= m+1){
        cout << "Sasha";
    }else{
        cout << "Anna";
    }
    cout << endl;
}

Excited for this!!!

Thanks bhaii

ai mod 2k = x;
ai mod 2k = x + 2k;

There must be x + 2k instead of x + k.

For example, let ai = 5 and k = 2:

5 % (2*2) = 1;

Hence, x is 1.

If we go with ai % (2k) = x + k, then:

1 + 2 != 5

But:

1 + 2*2 == 5;

TheScrasse

Let's wait till system testing finishes.

Wait for system testing.

someone tell the approach of PROBLEM D

Because there time complexity goes in order of O(n) in worst case and the same happens with unordered map also, while in simple amp and set the time complexity remains O(logn).

In problem B some people have pre-computed a string of length 30. How they are approaching that problem?

Explain you approach. Also why you are keeping n>= 10 ?