ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1026. Questions and Answers

Xeqlol My AC on C# [2] // Problem 1026. Questions and Answers 27 Oct 2010 20:01
maybe it is not the best solution, but

using System;
using System.Collections.Generic;

namespace _1026
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            List<int> z = new List<int>();
            for(int i = 0; i < n; i++)
                z.Add(int.Parse(Console.ReadLine()));
            z.Sort();
            Console.ReadLine();
            int k = int.Parse(Console.ReadLine());
            for (int i = 0; i < k; i++)
                Console.WriteLine(z[int.Parse(Console.ReadLine())-1]);

        }
    }
}
DR. Zhihua Lai Re: My AC on C# // Problem 1026. Questions and Answers 30 Nov 2011 03:21
well.... C# helps a lot. but i really think figure out yourself is better.
PS: no sort is required actually.
Vitaly Grebennik Re: My AC on C# // Problem 1026. Questions and Answers 29 Nov 2019 18:29
If you know the length of array it is better to create array, not to use List<>. Array is faster :) In this case you needn`t a lot of economy of time, but in some cases this can be critical.