USTC 1122 millionaire rank list

Source: Internet
Author: User
Millionaire rank listtime limit: 1000 ms
Memory limit: 131072 kbdescription

In the wild universe, there lives a race of clever creature. They have high level civilization and control a lot of planets.

As we human, some of us are very rich and the public like to know who are the top 10. as a journalist of a famous new paper, you are asked to write a program to get the top 10 list.

Input

The input contains only one test case.

The first line contains one integer N (10 <= n <= 1,000,000), which means there are n rich people in the race. the following n lines each contains a integer mi (mi> = 0), which means the money of the I-th person.

But as they are universal millionizer, they are very rich, which means the amount of their money can be as large as 1025.

Note that MI may have preceding zeros.

Output

Output 10 lines, containing the money of the richest 10 people in descending order. Delete the preceding zeros if they once have.

Sample Input
111234567891015
Sample output
151098765432
Source: 34th ACM/ICPC Asia Regional, Hefei, preliminary
Solution:
Sorting of large numbers. For large numbers, it is generally faster to read in C language. You only need to sort the top 10 sorting methods.
# Include <iostream> # include <cstring> using namespace STD; # define maxsize 1000000 char money [maxsize] [26]; bool compare (char a [], char B []) {int I, alength = strlen (A), blength = strlen (B); If (alength! = Blength) return alength> blength; else for (I = 0; I <alength; I ++) if (a [I]! = B [I]) return a [I]> B [I]; return 1 ;}int main () {int N, J, I; char temp [26]; scanf ("% d", & N); for (I = 0; I <n; I ++) {scanf ("% s ", & money [I]) ;}for (I = 0; I <10; I ++) for (j = I + 1; j <n; j ++) if (compare (money [J], money [I]) {strcpy (temp, money [I]); strcpy (money [I], money [J]); strcpy (money [J], temp) ;}for (I = 0; I <10; I ++) {printf ("% s/n ", money [I]);} return 0 ;}

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.