robchik's blog

By robchik, history, 11 months ago, In English

Hello,

Could the Rust version please be upgraded on Codeforces?

The current Rust version on Codeforces is 1.75 which was released in December of 2023. The latest Rust version is 1.87.

I tried to use the Vec::sorted function and it's missing in Rust 1.75. 325619184

Thank you!

Full text and comments »

  • Vote: I like it
  • +11
  • Vote: I do not like it

By robchik, history, 4 years ago, In English

So this problem came up when I was trying to calculate the maximum number of people that are all available for $$$k$$$ hours. Essentially the $$$j$$$-th bit of $$$a_i$$$ represents the availability of the $$$j$$$-th person at hour $$$i$$$. I am wondering if there is an efficient solution to this. Formally one could define the problem as follows:

The "score" of a number $$$x$$$ is defined as the number of 1s in the binary representation of $$$x$$$. For example, the score of 5 is 2, since 5 is 101 in binary.

You are given a list $$$A$$$ of $$$n$$$ integers: $$$0\leq a_1$$$, $$$a_2$$$, $$$a_3$$$, ..., $$$a_n\leq 2^{20}$$$. You are given an integer $$$k$$$ ($$$1\leq k\leq n$$$).

Your task is to choose exactly $$$k$$$ unique integers: $$$1 \leq$$$ $$$i_1$$$, $$$i_2$$$, ... $$$i_k$$$ $$$\leq n$$$, so that the "score" of the bitwise AND of $$$a_{i_1}, a_{i_2}, ... , a_{i_k}$$$ is maximum.

Print the integers $$$i_1$$$, $$$i_2$$$, ... $$$i_k$$$. If there are multiple answers, print any of them.

Any ideas on how to solve this?

Full text and comments »

  • Vote: I like it
  • +17
  • Vote: I do not like it