Problem A. Sorter Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 256 megabyt
Posted: Sat Nov 27, 2021 10:27 am
Problem A. Sorter Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 256 megabytes Almas loves to sort numbers with specific rules that he comes up with himself. Today he wants to sort rows, each row contain m integer elements. He decided to sort rows in decreasing order of their sum, i.e. the row with larger sum will be the first. In case the sums are equal, then he order rows lexicographically, i.e. The row with least first element will be the first, if first elements are equal, then compare second element, third element, etc. He successfully finished sorting. He wanted to put the result in the closet, but accidentally put it in the shredder and divided everything into rows again. Help him sort it again. Input The first line contains two numbers, n and m the number of rows and mumber of elements in a row. The next n lines contain m numbers, elements of each row. .1<n,m<500 • 0 <row < 5000 standard output Output Print rows in desired sorted order. Examples standard input 53 1 2 3 1 2 4 1 3 2 600 2 3 2 2 3 16 3 18 5 10 8 5 5 17 16 21 10 48 1 34 5 41 42 29 8 50 21 43 21 39 9 26 23 45 44 29 8 24 1 24 2 3 2 1 2 3 1 3 2 600 16 3 18 5 10 8 29 8 50 21 43 45 44 29 8 24 1 34 5 41 42 21 39 9 26 23 17 16 21 10 48