Hdu2093 (exam ranking)

Source: Internet
Author: User

Hdu2093 (exam ranking)

Click to open hdu2093

 

The real-time submission system used for the Problem DescriptionC ++ programming test has the characteristics of instant score ranking. How is its function implemented?
We have prepared answers to the questions. After the question is submitted, we can either "AC" or "error". No matter how wrong the question is, we always give you a note, indicating that you have submitted an error once, therefore, once you submit the question "AC", you have to calculate an account with you. In total, the question is incorrectly submitted several times. Although you have made great strides in the number of questions, you have to share the time spent. In particular, if you have submitted an error, you must set a certain unit time point each time. In this way, you may be ahead of others in terms of the number of questions you have made. However, you may be at a disadvantage in ranking people who have made the same number of questions in terms of time consumption.
For example, A single exam has eight questions (A, B, C, D, E, F, G, H ), each question is marked with a number under the corresponding question number. A negative number indicates the number of times that the student submitted an error on the question, a positive number indicates the time consumed by the AC. If positive a is followed by a pair of parentheses and there is an integer B in it, it indicates that the student submitted the question AC, which consumes time a. At the same time, B has been incorrectly submitted, so the following input data:



If the penalty score for each Incorrect submission is 20 points, the ranking from high to low should be as follows:
Joseph 5 376
John 4 284
Alice 4 352
Smith 3 167
Bob 2 325
Bush 0 0

The first line of Input data is the number of questions n (1 ≤ n ≤ 12) and unit penalty score m (10 ≤ m ≤ 20 ), each row of Data describes the user name of a student (a string of no more than 10 characters) and the answer status of all n questions. The description uses the number mark format in the question description, as shown in the preceding table, the number of submissions is always less than 100, and the time consumed by the AC is always less than 1000.


Output outputs a Real-Time ranking of the current status of these students. The real-time ranking is clearly based on the number of questions in the AC, the number of questions in the front, and the number of times in the front, if the first two are equal, the name is listed in the lexicographically ascending order. Each student occupies a row and outputs the name (10 characters in width). The number of questions (two characters in width, right alignment) and time (four characters in width and right alignment) are displayed ). There is a space between the name, number of questions, and time.

Sample Input
8 20Smith  -1-16800120390John  116-211008255(1)0Josephus  72(3)12610-304721(2)-2Bush  0-1-800000Alice  -267(2)13-1013379(1)-1Bob  0057(5)00168-70

Sample Output
Josephus    5  376John        4  284Alice       4  352Smith       3  167Bob         2  325Bush        0    0
Import java. util. extends; public class P2093 {public static void main (String [] args) {Using SC = new using (System. in); while (SC. hasNext () {int n = SC. nextInt (); int m = SC. nextInt (); Person [] p = new Person [1000]; int k = 0; while (SC. hasNext () {// String name = SC. next (); int time = 0, num = 0; for (int I = 0; I
 
  
0) {num ++; time ++ = timer + numb * m ;}} p [k ++] = new Person (name, num, time); // System. out. println (num = + num + time = + time);} sort (p, k); for (int I = 0; I
  
   
P [j + 1]. time) {swap (p, j, j + 1);} else if (p [j]. time = p [j + 1]. time) {if (p [j]. name. compareTo (p [j + 1]. name)> 0) {swap (p, j, j + 1) ;}}}} private static void swap (Person [] p, int j, int I) {Person temp = new Person (); temp = p [j]; p [j] = p [I]; p [I] = temp ;}} class Person {public String name; public int num; public int time; public Person (String name, int num, int time) {this. name = name; this. num = num; this. time = time ;}public Person (){}}
  
 


 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.