You are on page 1of 4

E

COMP6047 – Algorithm and Programming

T
T
NO
BU
Sorting
Jojo is asked to sort data that contains name and number based on number in descending
order. If the number is the same, then sort them based on name in ascending order.

I
Format Input

R
O
The first line contains an integer T stating the number of test cases. Each test case
contains an integer N which indicates N rows of data to be input. Each data consists of
T
a name and number. The format of each line of data is name#number.
D

Format Output
S
The output consists of T lines where each line has the format “Case #X:”, where X is
the test case number starting at 1 with an enter. For each test case, output the sorted
DI

data by number in descending order and name in ascending order with format name -
number. OT
Constraints

UT
RE

• 1 ≤ T ≤ 50

• 1 ≤ N ≤ 50

• 1 ≤ |Name| ≤ 50
N
• N ame will only consist of lowercase characters and spaces.
IB
• N ame will not contain leading or trailing spaces.

• Numbers will fit in integer data type.


TR
DO

Sample Input (standard input)


2
3
andi#30
IS

rudi setiawan#50
aben#30
5
andi#70
ED

© School of Computer Science - BINUS, 2021. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
Violators of this clause may be academically sanctioned.
E
COMP6047 – Algorithm and Programming

T
T
rudi setiawan#50
aben#70

NO
BU
rony sinardi#50
kurniati#60

Sample Output (standard output)

I
Case #1:
rudi setiawan - 50

R
O
aben - 30
andi - 30
Case #2:
aben - 70
T
D

andi - 70
kurniati - 60
S
rony sinardi - 50
rudi setiawan - 50
DI

Note
Even though it is not stated explicitly, you should know by now that excessive space /
OT
newline are treated as WRONG ANSWER.

UT
RE

N
IB
TR
DO
IS
ED

© School of Computer Science - BINUS, 2021. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
Violators of this clause may be academically sanctioned.
E
COMP6047 – Algorithm and Programming

T
T
NO
BU
Sorting
Jojo diminta untuk mengurutkan data yang berisi nama dan nomor berdasarkan nomornya
secara menurun. Jika angkanya sama, maka urutkan data berdasarkan nama secara
menaik

RI
O
Format Input
Baris pertama berisi bilangan bulat T yang menyatakan jumlah kasus uji. Setiap kasus
T
uji berisi bilangan bulat N yang menunjukkan N baris data yang ingin dimasukkan.
D

Setiap data terdiri dari nama dan nomor. Input format untuk tiap baris data adalah
nama#nomor.
S
Format Output
DI

Terdiri dari baris T di mana setiap baris memiliki format “Case #X:”, di mana X adalah
nomor kasus uji mulai dari 1 dengan sebuah enter. Untuk setiap kasus uji, keluarkan
data yang diurutkan berdasarkan nomor yang menurun dan nama menaik dengan format
nama - nomor.
OT
UT
RE

Constraints
• 1 ≤ T ≤ 50

• 1 ≤ N ≤ 50
N
IB
• 1 ≤ |Nama| ≤ 50

• N ama hanya akan memuat karakter lowercase dan spasi.

• N ama tidak akan memuat spasi leading atau trailing.


TR
DO

• Semua angka pasti akan muat ke tipe data integer.

Sample Input (standard input)


2
IS

3
andi#30
rudi setiawan#50
aben#30
ED

© School of Computer Science - BINUS, 2021. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
Violators of this clause may be academically sanctioned.
E
COMP6047 – Algorithm and Programming

T
T
5
andi#70

NO
BU
rudi setiawan#50
aben#70
rony sinardi#50
kurniati#60

I
Sample Output (standard output)

R
O
Case #1:
rudi setiawan - 50
aben - 30
andi - 30
T
D

Case #2:
aben - 70
S
andi - 70
kurniati - 60
rony sinardi - 50
DI

rudi setiawan - 50

Note
OT
UT
Meskipun tidak dinyatakan secara eksplisit, Anda harus tahu sekarang bahwa ruang /
RE

baris baru berlebihan diperlakukan sebagai WRONG ANSWER.


N
IB
TR
DO
IS
ED

© School of Computer Science - BINUS, 2021. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
Violators of this clause may be academically sanctioned.

You might also like