UBSEA team

UBSEA triumphs, dominating the Pacific Northwest programming arena

Once again, the Pacific Northwest International Collegiate Programming Contest (ICPC) competition saw a UBC team crushing it to take first place.

The three-man UBSEA team emerged victorious in an exhibition of programming prowess on their own turf in Vancouver at the regional ICPC contest.

The annual event was hosted by the university’s computer science department on Saturday, Feb. 24. Teams from B.C. as well as Washington, Oregon, North California, and Hawaii all vied for placement in the fast-paced, challenging competition that involved trying to solve 13 problems in a maximum 5-hour timeframe.

The winning UBC team, comprised of members Joel Gunawan, Vincent Ling, and Binh Nguyen, quickly knocked off the challenges, completing 11 of the 13 problems in just three hours (no team completed the remaining two problems), using their exceptional speed and teamwork to clinch the win.

Nationals next

For their first place finish, UBSEA automatically advances to the North American Championship in Florida, May 23 - 28, 2024, where they hope to then qualify for the world finals in Astana, Kazakhstan.

This accomplishment is not the first time a UBC team has advanced. Historically, UBC has performed extremely well in this competition, qualifying for the world finals in 16 out of the past 20 years. They continue to successfully beat out accomplished teams from Stanford, Berkeley, UW, SFU, and others. 

This competition is so popular amongst UBC students, that there were six teams participating in this year’s regional competition. All were co-coached by PhD student Xingyu Zhou and Master's student, Emily Gong, both of whom competed for UBC as undergrads.

UBC Computer Science Professor Will Evans is the faculty mentor and he organized the British Columbia site for the regional competition. Dr. Evan’s pride was evident, saying, “The students are amazingly talented and hardworking. They deserve all the praise.”

How did they win?

Speed seems to be the team's secret sauce. Team member Binh said, “We won the contest mostly by solving the problems faster than the other teams.” But also, when asked about the success of the team members, Zhou said, “I think the two most crucial factors are their robust backgrounds in competitive programming and their commitment to our weekly practices.” He explains that two of the UBSEA members, Nguyen and Gunawan, just joined the team in 2023 as first-year students, but came in super-prepared from having competed during high school in the International Olympiad in Informatics. Gunawan was even selected for Indonesia’s national team.

Zhou said they initially performed better as individuals than as a team, but since practicing together weekly since November, they have excelled. “With their persistent commitment, they have shown significant improvement, successfully tackling problems that initially posed challenges to each of them individually.” 

What kinds of problems did they solve?

The contest involves solving many very difficult and very different programming problems. The more difficult problems require designing complicated algorithms. 

Here’s a sample question from the problems in this year’s competition. Would you have what it takes to solve this quickly, using only the languages supported: C, C++ 20 (with Gnu extensions), Java, Python 3 (with pypy3), and Kotlin?

“Candy Factory”   Time Limit: 2 seconds, Memory limit: 2G

The International Consortium of Popular Candies (ICPC) is hosting a prestigious candy festival for candy lovers worldwide. The consortium has asked n candy factories to produce candies for the event. Each of the n factories has produced some quantity of a unique type of candy.

Packs of candies will be given to the participants at the festival. A candy pack must consist of exactly k candies of different types. Two candy packs may contain different sets of k candies.

There may be unavoidably some leftover candies given the quantities of candies that the n factories have already produced. The ICPC does not want to waste any of the candies produced, and is willing to create extra packs of candy to ensure this. The ICPC can order any of the n factories to produce additional candies. What is the minimum quantity of additional candies that must be ordered, so that there will be no leftover candies after packing?

Input

The first line of input has two integers n and k (1 ≤ k ≤ n ≤ 5 000).

The next n lines each have a single integer between 1 and 109. The integer on the ith line is the quantity of candies that the factory has produced.

Output

Output a single integer, the minimum quantity of additional candies that must be ordered.


Learn more about the UBC Competitive Programming Team and/or join the Discord group. If you have an interest in joining, please email zxingyu@cs.ubc.ca to learn about how they operate and when the next tryouts are scheduled for.

About the ICPC

The ACM International Collegiate Programming Contest (ICPC) is a multitier, team-based, programming competition operating under the Association for Computing Machinery (ACM). The contest involves a global network of universities hosting regional competitions that advance teams to the ACM-ICPC World Finals. Participation has grown to several tens of thousands of the finest students and faculty in computing disciplines. The contest fosters creativity, teamwork, and innovation in building new software programs, and enables students to test their ability to perform under pressure. Quite simply, it is the oldest, largest, and most prestigious programming contest in the world.