Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- class P09_JumpAround
- {
- static void Main(string[] args)
- {
- var numArray = Console.ReadLine()
- .Split(' ')
- .Select(int.Parse)
- .ToArray();
- int i = 0;
- int sum = 0;
- while (i >= 0)
- {
- if (i < numArray.Length)
- {
- sum += numArray[i];
- i = i + numArray[i] < numArray.Length ?
- i + numArray[i] :
- i - numArray[i];
- }
- }
- Console.WriteLine(sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement