ΠΔΠ-27 (2015) - Phase A (xxx)

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem types
Allowed languages
C, C++, Java, Pascal, Python

The school cafeteria

A group of children stand in a straight line, one behind the other, waiting for their turn at the school cafeteria. The first child obviously sees the entrance of the cafeteria, but for the children standing behind, it may not be certain if they can see it too. For a child to see the entrance of the cafeteria, all the children standing in front of them must be shorter than them.

Problem

Develop a program in one of the IOI languages that, after reading a file containing the heights of children, will print how many children see the entrance.

Input Files:

The input file (xxx.in) is a text file that contains only two lines. The first line contains an integer N: the number of children standing in line. The second line contains N integers, separated in pairs by a space. These numbers represent the heights of the children, given in the order they stand in line, from the back to the front. In other words, the first number on the second line is the height of the last child (the one farthest from the entrance of the cafeteria), and the last number is the height of the first child (the one closest to the entrance).

Output Files:

The output file (xxx.out) is a text file with the following format: It has only one line containing a single integer K\;(1 \le K \le N): the number of children who can see the entrance of the cafeteria.

Examples of Input - Output Files:
1st

STDIN (xxx.in)

7
5 6 4 6 3 4 1

STDOUT (xxx.out)

3

pdp-2015-A-fig-1.svg


2nd

STDIN (xxx.in)

4
23 17 7 42

STDOUT (xxx.out)

1

pdp-2015-A-fig-2.svg

Constraints:

1 \le N \le 1.000.000
Maximum execution time: 1sec.
Maximum available memory: 64MB.


Comments

There are no comments at the moment.