How Many Inputs?

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Task

Some times when data is being collected, from users, it is not possible to know how many data points there will be. In these circumstances the user is asked to indicate when the last valid input was provided by entering a unique value.

In this task users enter a series of positive integers as valid input and indicate when the data has all been entered by entering -1 (an invalid input).

Write a program that takes an unknown number of integers, as input, and then outputs how many valid inputs there were on one line, and the sum of the valid integers on a second line.

Example

5
7
4
-1
3
16

2025 OUCC

未参加
状态
已结束
规则
IOI
题目
17
开始于
2025-5-4 17:00
结束于
2025-5-4 19:30
持续时间
2.5 小时
主持人
参赛人数
2