aryanc403's blog

By aryanc403, 2 years ago, In English

1997A - Сильный пароль

Hint
Video editorial

1997B - Создайте три региона

Idea
Video editorial

1997C - Четные позиции

Hint
Discussion

1997D - Максимизация корня

Video editorial

1997E - Прокачка персонажа

Hint 1
Hint 2
Hint 3
Hint 4
Video editorial
Daily Chat QnA
  • Vote: I like it
  • +10
  • Vote: I do not like it

»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

My answer for the part D is giving wrong answer on 19th test case

bool check(map<ll, vector<ll>> &mp, vector<ll> &a, ll k){

    queue<pair<ll, ll>> qu;
    for(ll i: mp[1]) qu.push({i, k - a[1]});

    while(!qu.empty()){
        auto curp = qu.front(); qu.pop();
        ll cur = curp.first;
        ll sub = curp.second;

        ll moda = a[cur] - sub;

        if(mp[cur].size() == 0 && moda < 0) return false;

        if(moda < 0) sub -= moda;

        for(ll i: mp[cur]) qu.push({i, sub});
    }

    return true;
}

can somebody help?