-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
57 lines (46 loc) · 1.05 KB
/
Program.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections.Generic;
using System.Linq;
namespace BreakingRecords
{
class Result
{
/*
* Complete the 'breakingRecords' function below.
*
* The function is expected to return an INTEGER_ARRAY.
* The function accepts INTEGER_ARRAY scores as parameter.
*/
public static List<int> breakingRecords(List<int> scores)
{
var result = new List<int>() { 0, 0 };
int maxScore = scores[0];
int minScore = scores[0];
foreach (var score in scores)
{
if (score > maxScore)
{
result[0]++;
maxScore = score;
}
if (score < minScore)
{
result[1]++;
minScore = score;
}
}
return result;
}
}
class Program
{
static void Main(string[] args)
{
int n = Convert.ToInt32(Console.ReadLine().Trim());
List<int> scores = Console.ReadLine().TrimEnd().Split(' ').ToList().Select(scoresTemp => Convert.ToInt32(scoresTemp)).ToList();
List<int> result = Result.breakingRecords(scores);
Console.WriteLine(String.Join(" ", result));
Console.ReadKey();
}
}
}