ED - Taller Practico 1
ED - Taller Practico 1
Desarrolle cada uno de los siguientes puntos a partir de los conceptos vistos en clase,
y coloquelos en su repositorio de GitHub, colocando en los comentarrios del código la
estrategia que utilizo para resolverlos:
Input:
The i-th line of input refers to a dragon sent by Sauron to Daenerys and consists of
two integers: Ti e Fi (1 ≤ Ti , Fi ≤ 103 ), representing respectively the number of days
needed to train the i-th dragon and the fine charged per day that the dragon spends
sleeping. For any distinct i and j, Ti /Fi 6= Tj /Fj . The input has at most 105 lines
and ends in end of file.
Output:
Output a line containing singly the total value of the fine that Daenerys will pay to
Sauron if she follows your advices.
Input:
The first line of input contains an integer N that indicates the amount of trips of
Dona Parcinova to the market (which is nothing more than the number of test cases).
Each test case starts with an integer M which is the quantity of products with prices
that are available for sale at the market. Follow M products with their respective
prices per unit or Kg. The next input line contains an integer P (1 ≤ P ≤ M )
that indicates the list of products that Ms. Parcinova want to buy. Follow P lines
containing a string (with up to 50 chars) and an integer, representing each item with
the desired quantity of this item.
Output:
Each test case produce one output line, containing the money spent by Ms. Parcinova
in the following format: R$ followed by a space and followed by the spent money, with
2 places after the decimal point according to the following example.
DATA STRUCTURES - PRACTICAL ASSIGNMENT NO. 1 3
Input:
First line consists of a single integer denoting N . Second line consists of N space
separated integers denoting the array A.
Output:
Print N space separated integers, denoting x + y for each i (1 ≤ i ≤ N ).
DATA STRUCTURES - PRACTICAL ASSIGNMENT NO. 1 4
Now Albus Dumbledore asked Little Monk to tell him the order in which student put
their name. Little Monk is too lazy to that so he asked you to write a program to
print required order.
Note: Number of dequeue operations will never be greater than enqueue operations
at any point of time.
Input:
First line contains an integer Q (1 ≤ Q ≤ 100000), denoting the number of operations.
Next Q lines will contains one of the 2 types of operations.
Output:
For each 2nd type of operation, print two space separated integers, the front student’s
school and roll number.
DATA STRUCTURES - PRACTICAL ASSIGNMENT NO. 1 5
Input:
The first line consists of a single integer N (1 ≤ N ≤ 10) denoting the number of
stacks. In each of the next N lines, first integer X (0 ≤ X ≤ 105 ) denotes the size
of the stack, followed by the X space separated integers denoting the heights of the
fighters in the stack (1 ≤ height of each f ighter ≤ 109 ).
The next lines consists of single integer Q (1 ≤ Q ≤ 250000), denoting the
number operations. Each of the next Q lines will contain a integer v (1 ≤
number of operations with (v = 2) ≤ 104 ), which will decide the type of opera-
tion.
DATA STRUCTURES - PRACTICAL ASSIGNMENT NO. 1 6
• For v = 1, extra 2 integers k and h will be given, which shows that Voldemort
will add one fighter of height h in k-th stack, maintaining the order of the stack,
if k 6= 1.
• For v = 0, 1 more integer k will be given, which shows that Voldemort will
remove a fighter from k-th stack.
• For v = 2, Monk needs to know whether Harry can use his special wand or not.
Output:
For each v = 2, print "YES" (without quotes) if Harry can use his special wand or
print "NO" (without quotes).