Input expectations

3.1

28 votes
Arrays, Basic Programming, Basic Math, Math,
Problem

Consider the following program:

    int t;
    cin >> t;

    for(int i = 0; i < t; i++){
        int n;
        cin >> n;
        for(int i = 0; i < n; i++){
             int temp;
             cin >> temp;
        }
    }
    cout << "END OF THE PROGRAM";


This program accepts the input as follows:

t

n

a1a2a3...an

n

a1a2a3...an

.

.

.

n

a1a2a3...an

And, then prints "END OF THE PROGRAM".

Suppose you provide following input to the program:

n

a1a2a3...an

The program might expect more numbers.
How many more numbers does the program must be given to get the "END OF THE PROGRAM" output. If there are multiple answers, then print the minimum answer.

Input format

  • The first line will contain an integer n. (1n1000000)
  • The second line contains n space-separated integers (1ai1000000):
    • n
    • a1a2a3...an

Output format

Print a single integer denoting the answer to the problem.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

5
1 2 3 1 2
The program will interpret the above input as follows:
5
1
2
3
1 2 x (The program expects some number here)
y (=0 for the minimum answer. Here the inner loop won't execute)
z (=0 for the minimum answer. Here the inner loop won't execute)
Now the program outputs "END OF THE PROGRAM"
So, the minimum number of numbers that the program expects is 3. 

Editor Image

?