[Codeforces] School Personal Contest #2 (Winter Computer School 2010/11) - Codeforces Beta Round 43 (ACM-ICPC Rules) E. CombRead more
[Codeforces] Beta Round 51 C. Pie or dieRead more
[Codeforces] Beta Round 53 C. ArrayRead more
[Codeforces] Beta Round 57 (Div. 2) E. Enemy is weakRead more
[Codeforces] Beta Round 59 (Div. 2) D. Dividing IslandRead more
[LeetCode] Maximum Element-Sum of a Complete Subset of Indices

2862. Maximum Element-Sum of a Complete Subset of Indices

You are given a 1**-indexed** array nums of n integers.

A set of numbers is complete if the product of every pair of its elements is a perfect square.

For a subset of the indices set {1, 2, ..., n} represented as {i1, i2, ..., ik}, we define its element-sum as: nums[i1] + nums[i2] + ... + nums[ik].

Return the maximum element-sum of a complete subset of the indices set {1, 2, ..., n}.

A perfect square is a number that can be expressed as the product of an integer by itself.

Read more
[LeetCode] Maximum Number of Alloys

2861. Maximum Number of Alloys

You are the owner of a company that creates alloys using various types of metals. There are n different types of metals available, and you have access to k machines that can be used to create alloys. Each machine requires a specific amount of each metal type to create an alloy.

For the ith machine to create an alloy, it needs composition[i][j] units of metal of type j. Initially, you have stock[i] units of metal type i, and purchasing one unit of metal type i costs cost[i] coins.

Given integers n, k, budget, a 1-indexed 2D array composition, and 1-indexed arrays stock and cost, your goal is to maximize the number of alloys the company can create while staying within the budget of budget coins.

All alloys must be created with the same machine.

Return the maximum number of alloys that the company can create.

Read more
[LeetCode] Happy Students

2860. Happy Students

You are given a 0-indexed integer array nums of length n where n is the total number of students in the class. The class teacher tries to select a group of students so that all the students remain happy.

The ith student will become happy if one of these two conditions is met:

  • The student is selected and the total number of selected students is strictly greater than nums[i].
  • The student is not selected and the total number of selected students is strictly less than nums[i].

Return the number of ways to select a group of students so that everyone remains happy.

Read more
[LeetCode] Sum of Values at Indices With K Set Bits

2859. Sum of Values at Indices With K Set Bits

You are given a 0-indexed integer array nums and an integer k.

Return an integer that denotes the sum of elements in nums whose corresponding indices have exactly k set bits in their binary representation.

The set bits in an integer are the 1‘s present when it is written in binary.

  • For example, the binary representation of 21 is 10101, which has 3 set bits.
Read more
[Codeforces] Manthan 2011 D. Optical ExperimentRead more