Prob D
Prob D
T
T
NO
BU
Simple Party Finding
Minions Legends is a multiplayer online battle arena (MOBA) mobile game. In this
game, each player will be grouped with another player to form a team. The team will
fight another team to defend their sacred ancient and to destroy their opponent’s base.
I
In the next patch, the developers of the game want to create a simple party finding
R
O
algorithm which can match two players based on their matchmaking rating (MMR). In
their implementation, a player will be grouped with the player with the lowest MMR that
is higher than their MMR. If a player has the highest MMR, they will be grouped with
T
the player with the highest MMR that is lower than their MMR.
D
S
Format Input
The first line contains integer K which denote as the number of cases. The second line
DI
contains integer N stating the total number of players. Then, the third line consists of
N MMR in the game. Lastly, the fourth line contains of F which denote as the player’s
MMR who wants to find a party. It is guaranteed that the MMR are distinct.
OT
UT
RE
Format Output
Output with a format “CASE #K: [MMR 1] [MMR 2]”; where MMR 1 and MMR 2 are
the result of party finding. Note that MMR 1 is the one with the lower MMR compared
to MMR 2. If the inputted MMR’s number is not in the list of players, give an output
“CASE #K: -1 -1”.
N
IB
Constraints
• 1 ≤ K ≤ 100
TR
• 2 ≤ N ≤ 1000
DO
• 3000 ≤ M M R ≤ 9999
• 3000 ≤ F ≤ 9999
IS
© 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
3
NO
BU
10
3246 4255 4873 5004 5095 6001 6692 7100 7610 9712
9712
8
4957 5444 5464 5634 6149 6622 8313 9492
4957
6
I
5393 6021 7233 8115 8118 9304
R
9999
O
Sample Output 1 (standard output)
T
D
OT
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
Simple Party Finding
Minion Legends adalah sebuah permainan mobile multiplayer online battle arena (MOBA).
Dalam permainan ini, setiap pemain akan dipasangkan dengan pemain lain untuk membuat
sebuah tim; Tim tersebut akan melawan tim lain untuk menjaga sacred ancient mereka
dan menghancurkan markas lawan.
RI
O
Dalam patch selanjutnya, para pengembang permainan ini ingin membuat sebuah algoritma
sederhana untuk mencari party yang dapat memasangkan dua pemain berdasarkan matchmaking
rating (MMR) mereka. Dalam implementasi mereka, seorang pemain akan dipasangkan
T
dengan pemain lain yang memiliki MMR terkecil yang lebih tinggi dari MMR mereka.
D
Jika seorang pemain memiliki MMR terbesar, dia akan dipasangkan dengan pemain yang
memiliki MMR terbesar yang lebih rendah dari MMRnya.
S
Format Input
DI
Baris pertama berisi integer K yang menunjukkan jumlah testcase. Baris kedua berisi
integer N yang menunjukkan jumlah pemain. Baris ketiga berisi N buah MMR dalam
permainan. Terakhir, baris keempat berisi F , yaitu MMR pemain yang ingin mencari
OT
UT
party. Dipastikan semua MMR unik.
RE
Format Output
Output dengan format “CASE #K: [MMR 1] [MMR 2]”; dimana MMR 1 dan MMR 2
adalah hasil dari pencarian party, dimana MMR 1 adalah MMR pemain yang lebih
N
IB
rendah dari MMR 2. Jika MMR yang diinput tidak ada dalam list MMR pemain, berikan
output “CASE #K: -1 -1”.
Constraints
TR
DO
• 1 ≤ K ≤ 100
• 2 ≤ N ≤ 1000
• 3000 ≤ M M R ≤ 9999
• 3000 ≤ F ≤ 9999
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
Sample Input 1 (standard input)
NO
BU
3
10
3246 4255 4873 5004 5095 6001 6692 7100 7610 9712
9712
8
4957 5444 5464 5634 6149 6622 8313 9492
I
4957
6
R
O
5393 6021 7233 8115 8118 9304
9999
T
D
OT
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.