fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace ConsoleApp2
  5. {
  6. class Program
  7. {
  8. static void Main()
  9. {
  10.  
  11. int D = Convert.ToInt32(Console.ReadLine());
  12. while (D > 0)
  13. {
  14. int N = Convert.ToInt32(Console.ReadLine());
  15.  
  16.  
  17. string[] lista = Console.ReadLine().Split(' ');
  18. List<int> listaA = new List<int>(Array.ConvertAll(lista, arrTemp =>
  19. Convert.ToInt32(arrTemp)));
  20. listaA.Sort();
  21.  
  22. int maxiA = (listaA[N - 1]);
  23.  
  24. listaA.RemoveAt(N-1);
  25.  
  26. listaA.Sort();
  27. int maxiB = listaA[listaA.Count - 1];
  28.  
  29. if (maxiA == maxiB)
  30. {
  31. Console.Write(maxiA + " " + maxiB + " ");
  32. listaA.RemoveAt(listaA.Count - 1);
  33. foreach (var item in listaA)
  34. {
  35. Console.Write(item + " ");
  36. }
  37. Console.WriteLine();
  38. }
  39. else
  40.  
  41. {
  42. Console.Write(maxiA + " ");
  43.  
  44. foreach (var item in listaA)
  45. {
  46. Console.Write(item + " ");
  47. }
  48. Console.WriteLine();
  49. }
  50. D--;
  51. }
  52.  
  53.  
  54. }
  55. }
  56. }
Runtime error #stdin #stdout #stderr 0.03s 23140KB
stdin
1
1
1
stdout
Standard output is empty
stderr
Unhandled Exception:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <6649516e5b3542319fb262b421af0adb>:0 
  at ConsoleApp2.Program.Main () [0x00079] in <576884b6f0db40bb8ae37ad668b767c6>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <6649516e5b3542319fb262b421af0adb>:0 
  at ConsoleApp2.Program.Main () [0x00079] in <576884b6f0db40bb8ae37ad668b767c6>:0