Ni Wendi will accompany you to learn the Blue Bridge Cup 2021 Winter Holiday. One question per day: 1.25 (2019 Provincial Competition Group A Question 3)

There will be one question every day during the winter vacation of 2021, and the real question for the provincial competition from 2017 to 2019. The content of this article was provided by Ni Wendi (Class 192, Computer Department, East China University of Science and Technology) and Luo Yongjun. One question a day, follow the Blue Bridge Cup column: https://blog.csdn.net/weixin_43914593/category_10721247.html

Each question provides code in three languages: C++, Java and Python .

Question 3 " Maximum Rainfall " for Group A of the 2019 Provincial Competition , link to the topic:
http://oj.ecustacm.cn/problem.php?id=1454

1. Title description

fill in the blank.


Due to the years of drought in the land of sand, the mage Xiao Ming prepared to cast his own mysterious spell to pray for rain.
This spell requires 49 spell symbols in his hand, with 49 numbers from 1 to 49 written on them.
The spell lasts for 7 weeks, and Xiao Ming uses a spell talisman every day. The spell talisman cannot be reused.
Every week, the energy produced by Xiaoming's spells is the median of the numbers on the 7 spell symbols this week.
After 7 weeks of casting the spell, the rain request will be successful, and the rainfall is the median energy of 7 weeks.
Due to the drought for too long, Xiao Ming hopes that the rainfall for this request will be as large as possible. What is the maximum value?


2. Problem solution

  This question is boring, boring!

  The 7 days of the first week are placed in the first row, and the second week is placed in the second row.... is a 7*7 grid.
  Sort each row in order, the median is the middle number. There are 7 numbers in a row, and the median is the fourth. Then sort the 7 rows according to the middle number. The question is to ask how big the middle number X can be.
  The three on the left of each row are definitely smaller than the fourth, and the middle number of the first three rows is smaller than X. These are marked in blue, which is the smaller part of the 49 numbers.
  Next, look at the green part, they are better than X. If it is larger than X, then X has to be a smaller number.
  Finally, the gray (including X) is the largest number, there are 16 in total. X is the smallest of these numbers, so X=49-16+1=34.
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_43914593/article/details/112979549