-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA. Baloons.cs
43 lines (38 loc) · 1.12 KB
/
A. Baloons.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication13
{
class Program
{
static void Main(string[] args)
{
String[] init = Console.ReadLine().Split(' ');
int all = int.Parse(init[0]);
int selected = int.Parse(init[1]);
int [] baloons = Console.ReadLine().Split().Select(int.Parse).ToArray();
List<int> final = new List<int>();
int distinct = 1;
final.Add(baloons[0]);
for (int i = 1; i < all; i++)
{
if (baloons[i - 1] != baloons[i])
{
distinct++;
final.Add(baloons[i]);
}
}
while (final.Count < selected)
{
Random rnd = new Random();
final.Add(baloons[rnd.Next(0, baloons.Length)]);
}
for (int i = 0; i < final.Count; i++)
{
Console.Write(final[i] + " ");
}
Console.ReadLine();
}
}
}