-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathProgram.cs
More file actions
31 lines (23 loc) · 808 Bytes
/
Program.cs
File metadata and controls
31 lines (23 loc) · 808 Bytes
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
using System;
namespace Picking_Numbers {
class Program {
static int PickingNumbers(int n, int[] a) {
int retValue = 0;
for (int i = 0; i < n; i++) {
int count = 0;
for (int j = 0; j < n; j++) {
if (((a[i] - a[j]) >= 0) && ((a[i] - a[j]) <= 1)) {
count++;
}
}
if (count > retValue) retValue = count;
}
return retValue;
}
static void Main(string[] args) {
int n = Convert.ToInt32(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), aTemp => Convert.ToInt32(aTemp));
Console.WriteLine("{0}", PickingNumbers(n, a));
}
}
}