-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathProgram.cs
More file actions
30 lines (23 loc) · 805 Bytes
/
Program.cs
File metadata and controls
30 lines (23 loc) · 805 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
using System;
namespace Jumping_on_the_Clouds {
class Program {
public static int JumpingOnClouds(int[] ar) {
int jumps = 0;
for (int i = 0; i < ar.Length; i++) {
if ((i + 2) < ar.Length && ar[i + 2] == 0) {
jumps++;
i++;
} else if ((i + 1) < ar.Length && ar[i + 1] == 0) {
jumps++;
}
}
return jumps;
}
static void Main(string[] args) {
int n = Convert.ToInt32(Console.ReadLine());
int[] ar = Array.ConvertAll(Console.ReadLine().Split(' '), arTemp => Convert.ToInt32(arTemp));
int result = JumpingOnClouds(ar);
Console.WriteLine(result);
}
}
}