Https://hack.codingblocks.com/app/contests/1435/733/problem

How to solve this problem please explain i havent solved ever probablity based problems

@AyushKumar9032,
Not even school? In which class are you?
Anyways, E(x) = x.P(x), where x is an Random Variable, P(x) is probability of R.V x, E(x) is expected value of x.

So, probability of choosing a number between [1,9] out of 100 is 9/100, and number of children that can do that = n(given), so expected number of students who choose number<10 are n*(9/100)

1 Like

Can you also please explain my this query i have recently learnt priority queues and stl features but don’t know how to use pair inside priority queues. please help @abhijeet.srivastava6499

In the link below i want to understand a put function which is a part of codeforces submitted solution a video is also available on what is the algorithm used in it

@AyushKumar9032,
Watch the video then, what am I supposed to tell you?

i am not able to understood a part of it i understood int main function which he told in video but not put() function

his accepted code on codefoces link : https://codeforces.com/contest/1118/submission/50541968

@AyushKumar9032,
Read this blog, I think it has a clear explanation of your so called put function

can you please tell put function how is he using it uses priority queue i know how to use priority_queue<int,int> q1;

void put(vector<pair<int, int>> pos) {
auto t(q.top()); // here t is an object declared or what
q.pop();
if (t.first < pos.size()){ // can you tell how is it being compared
cout << “NO” << endl;
exit(0);
}
for (pair<int, int> p: pos)
a[p.first][p.second] = t.second;
t.first -= pos.size();
q.push(t);
}

@AyushKumar9032,
storing top element(a pair)of queue in variable t,
poping top element from queue,
some if else with the value of t.first, and t.second.
iterating over vector of pairs pos,
some logic
pushing updated pair in queue.

editorial is more hard for me to undertstand i have recently learnt stl basics so

this part isnt clear

if (t.first < pos.size()){
        cout << "NO" << endl;
    	exit(0);
    }
    for (pair<int, int> p: pos)
        a[p.first][p.second] = t.second;
    t.first -= pos.size();
    q.push(t);