Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _2.Icarus
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> arr = Console.ReadLine().Split().Select(int.Parse).ToList();
- int startPos = int.Parse(Console.ReadLine());
- string[] direction = Console.ReadLine().Split().ToArray();
- int damage = 1;
- while (direction[0] != "Supernova")
- {
- int steps = int.Parse(direction[1]);
- string dir = direction[0];
- if (dir=="right")
- {
- int countDamage = 0;
- for (int i = startPos + 1; i <= startPos+steps; i++)
- {
- if (i <= arr.Count - 1)
- {
- arr[i] -= damage;
- if(i==startPos+steps)
- {
- startPos = i;
- break;
- }
- }
- else if (i >= arr.Count)
- {
- countDamage++;
- if ((countDamage == 1)||(i % arr.Count == 0))
- {
- damage++;
- }
- arr[i % arr.Count] -= damage;
- if(i==startPos+steps)
- {
- startPos = i % arr.Count;
- break;
- }
- }
- }
- }
- else if(dir=="left")
- {
- int countDamage = 0;
- for (int i = startPos-1; i >= startPos-steps; i--)
- {
- if(i>=0)
- {
- arr[i] -= damage;
- if(i==startPos-steps)
- {
- startPos = startPos - steps;
- break;
- }
- }
- else
- {
- int temp = i;
- int help = arr.Count;
- i += arr.Count;
- if(i<0)
- {
- i += arr.Count;
- help *= 2;
- }
- countDamage++;
- if ((countDamage==1)||(i % arr.Count==0))
- {
- damage++;
- }
- arr[i] -= damage;
- i = temp;
- if(i== startPos - steps)
- {
- startPos = i + help;
- break;
- }
- }
- }
- }
- direction = Console.ReadLine().Split().ToArray();
- }
- Console.WriteLine(string.Join(" ",arr));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment