How do I write this java program? The manatees have been streaming many movies over the course of the last year. You have been asked to determine the movie they think will win "Best Aquatic Feature Film." For your convenience, the movies are numbered (1 <= N <= 50,000) and the actual titles of the movies are not important. The manatees have voted in two rounds, and number of votes received for each movie is recorded. As many as 109109 manatees world-wide may vote. The K (1<=K<=N) movies with the most votes in the first round will advance to the second round. The winner is the movie with largest vote total in the second round. Ties are broken in both cases by picking the movie with the higher index number. Determine which movie comes in first place and which movie comes in last place in the second round. Input format All the input comes from the standard input stream. Line 1: Two space-separated integers: N and K Lines 2..N+1: Line i+1 contains two space-separated integers: Ai�� and Bi��, where Ai�� is the votes for the movies in round 1 and Bi�� is the votes for the movies in round 2. Sample Input 5 3 3 10 9 2 5 6 8 4 6 5 In this sample, there are 5 movies, 3 of which will advance to the second round. The movies received 3, 9, 5, 8, and 6 votes, respectively, in the first round, and 10, 2, 6, 4, and 5 votes, respectively, in the second. Output format The output consists of two numbers. Sample output 5 2 Movies 2, 4, and 5 advance to the second round; In the second round, movie 5 gets 5 votes and gets first place and movie 2 gets 2 votes and gets last place. Hints:   Use records to keep the index, the first round votes, and the second round votes together. Sort twice using Comparator.comparing with Arrays.sort

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

How do I write this java program?

The manatees have been streaming many movies over the course of the last year. You have been asked to determine the movie they think will win "Best Aquatic Feature Film." For your convenience, the movies are numbered (1 <= N <= 50,000) and the actual titles of the movies are not important. The manatees have voted in two rounds, and number of votes received for each movie is recorded. As many as 109109 manatees world-wide may vote. The K (1<=K<=N) movies with the most votes in the first round will advance to the second round. The winner is the movie with largest vote total in the second round. Ties are broken in both cases by picking the movie with the higher index number.

Determine which movie comes in first place and which movie comes in last place in the second round.

Input format

All the input comes from the standard input stream.

  • Line 1: Two space-separated integers: N and K
  • Lines 2..N+1: Line i+1 contains two space-separated integers: Ai�� and Bi��, where Ai�� is the votes for the movies in round 1 and Bi�� is the votes for the movies in round 2.

Sample Input

5 3 3 10 9 2 5 6 8 4 6 5

In this sample, there are 5 movies, 3 of which will advance to the second round. The movies received 3, 9, 5, 8, and 6 votes, respectively, in the first round, and 10, 2, 6, 4, and 5 votes, respectively, in the second.

Output format

The output consists of two numbers.

Sample output

5 2

Movies 2, 4, and 5 advance to the second round; In the second round, movie 5 gets 5 votes and gets first place and movie 2 gets 2 votes and gets last place.

Hints:

 

  • Use records to keep the index, the first round votes, and the second round votes together.
  • Sort twice using Comparator.comparing with Arrays.sort
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education