Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp1
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. List<int> results = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  14. List<int> initialResults = results.ToList();
  15. int brizpitvaniq = int.Parse(Console.ReadLine());
  16. bool broken = false;
  17. for (int i = 1; i <= brizpitvaniq; i++)
  18. {
  19. int[] marks = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  20. int studentNum = marks[0];
  21. int result = marks[1];
  22. if(results.Count==0)
  23. {
  24. Console.WriteLine("All studets has been expelled due bad results!");
  25. broken = true;
  26. break;
  27. }
  28. if (result < results[studentNum])
  29. {
  30. results[studentNum] = results[studentNum] - result;
  31. }
  32. else if (result > results[studentNum])
  33. {
  34. results[studentNum] = results[studentNum] + result;
  35. }
  36. if (results[studentNum]*2<initialResults[studentNum])
  37. {
  38. results.Remove(results[studentNum]);
  39. initialResults.Remove(initialResults[studentNum]);
  40. }
  41. }
  42. if (broken == false)
  43. {
  44. Console.WriteLine(string.Join("; ", results));
  45. }
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement