-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathBear And Finding Criminals.cs
67 lines (55 loc) · 1.64 KB
/
Bear And Finding Criminals.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
58
59
60
61
62
63
64
65
66
67
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class problem_8june2016_02
{
static void Main()
{
int[] int_line1 = Console.ReadLine().Split(new char[] { ' ' }).Select(int.Parse).ToArray();
int[] int_line2 = Console.ReadLine().Split(new char[] { ' ' }).Select(int.Parse).ToArray();
int int_cities = int_line1[0];
int int_capital = int_line1[1]-1;
int int_result = 0;
List<int> list_left = new List<int>();
List<int> list_right = new List<int>();
for (int i = 0; i < int_cities; i++)
{
if (i < int_capital)
{
list_left.Add(int_line2[i]);
}
if (i > int_capital)
{
list_right.Add(int_line2[i]);
}
}
list_left.Reverse();
int max_len = Math.Min(list_left.Count, list_right.Count);
int another_len = Math.Max(list_left.Count, list_right.Count);
for (int i = 0; i < max_len; i++)
{
if (list_left[i]==list_right[i])
{
int_result += list_left[i] * 2;
}
}
//list_left.Reverse();
List<int> list_last = new List<int>();
if (list_left.Count>list_right.Count)
{
list_last = list_left;
}
else
{
list_last = list_right;
}
for (int i = max_len; i < another_len ; i++)
{
int_result += list_last[i];
}
int_result += int_line2[int_capital];
Console.WriteLine(int_result);
}
}