Open In App

Contest Experiences | Codeforces Round: #852 (Div. 2)

Last Updated : 30 Nov, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

ABOUT THE CONTEST:

  • This contest was conducted by Codeforces #852 for Div 2 Participants.
  • In this contest, there were 6 questions, and 2 hours and 15 minutes were given to solve these questions.
  • The penalty was 10 minutes for each wrong submission.

Link of the Contest: https://codeforces.com/contest/1793

My Experience:

I was able to solve 5 problems out of 6 problems during these contests.

OVERVIEW OF ALL CONTEST PROBLEM:

Problem Name

Difficulty

Approx. time to solve

Number of submissions by me

Yet Another Promotion

Easy

8 – 10 minutes

1

Fedya and Array

Easy-Medium

8 – 10 minutes

1

Dora and Search

Easy-Medium

10 – 15 minutes

2

Moscow Gorillas

Medium-Hard

10 – 15 minutes

1

Velepin and Marketing

Medium-Hard

20 – 25 minutes

2

Rebrending

Hard

LET’S DISCUSS THE QUESTIONS:

Problem A- Yet Another Promotion

Approach: First calculate the cost for buying n kilograms of potatoes on the first day without considering the promotion. This is n * a. Then calculate the number of times you can use the promotion. This is n // m. After that calculate the cost of using the promotion. This is (n // m) * b. Calculate the remaining kilograms of potatoes after using the promotion. This is n % m. Calculate the cost of buying the remaining potatoes on the first day without the promotion. This is (n % m) * a. At last add the costs from above steps to get the total minimum cost.

Problem B- Fedya and Array

Approach: To solve this first calculate the absolute values of x and y to simplify the problem. Determine the length of the array as the sum of absolute values of x and y. Create an array of zeros with a length of n. Alternate between increasing and decreasing values in the array to ensure that it represents a sequence of local maximums and local minimums. Adjust the sign of the first element based on the sign of x. Reverse the array if the original x was negative to match the required signs of x and y.

Problem C – Dora and Search

Approach: To solve this first reads an array of integers and finds the positions of the first occurrences of two distinct integers, k and l, in the array. It searches from both ends and prints the indices [i, j] where k and l are found. If they are not found, it prints -1.

Problem D- Moscow Gorillas

Approach: Initialize arrays to keep track of the last positions of elements in p and q. Initialize counters for suitable pairs and the current MEX values for p and q. Iterate through both permutations, updating MEX values as we go. Whenever the MEX values for p and q are equal, increment the pair counter. At last print the count of suitable pairs found.

Problem E- Velepin and Marketing

Approach: Read the input, which includes the number of readers, the number of readers required for each person’s happiness, the number of years to analyze, and the number of books Velepin needs to write in each year. Sort the array of required readers for happiness in non-decreasing order. Calculate the cumulative sum of the sorted array. This sum at position i represents the number of readers that can be satisfied if the top i books are written and assigned to the readers. For each year, calculate the maximum number of satisfied readers by considering the cumulative sum. At the end output the maximum number of satisfied readers for each year.

Conclusion:

At the end of this contest I was able to solve A , B ,C, D,E problem. Last F problem was difficult for me. All the best for upcoming contest.
Thank You !!!


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads