Advertisement
svetlyoek

Untitled

Feb 23rd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApp184
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int[] numbers= Console.ReadLine().Split().Select(int.Parse).ToArray();
  12. PrintWinner(numbers);
  13.  
  14. }
  15.  
  16. private static void PrintWinner(int[] numbers)
  17. {
  18.  
  19. double leftCarSum = 0;
  20. double rightCarSum = 0;
  21. for(int left=0;left<(numbers.Length/2);left++)
  22. {
  23.  
  24. if(numbers[left]==0)
  25. {
  26. leftCarSum *= 0.8;
  27. }
  28. else
  29. {
  30. leftCarSum += numbers[left];
  31. }
  32. }
  33. for(int right=numbers.Length-1;right>numbers.Length/2;right--)
  34. {
  35.  
  36. if(numbers[right]==0)
  37. {
  38. rightCarSum *= 0.8;
  39. }
  40. else
  41. {
  42. rightCarSum += numbers[right];
  43. }
  44. }
  45. if(leftCarSum<rightCarSum)
  46. {
  47. Console.WriteLine($"The winner is left with total time: {leftCarSum}");
  48. }
  49. else if(rightCarSum>leftCarSum)
  50. {
  51. Console.WriteLine($"The winner is right with total time: {rightCarSum}");
  52. }
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement