#C1569. Finding the Most Profitable Day

    ID: 44788 Type: Default 1000ms 256MiB

Finding the Most Profitable Day

Finding the Most Profitable Day

Given a series of financial transactions, your task is to determine the day with the highest overall profit. Each transaction is provided on a separate line either as a numerical value (which can be positive or negative) or as the string \(\text{END}\) which indicates the end of a day.

The profit of a day is defined as the sum of all the transaction values recorded before an \(\text{END}\). In case of a tie, output the earliest day (days are 1-indexed). If no transactions are provided (empty input), output 1.

Note: All numerical values are in floating-point format and may include decimals.

inputFormat

The input consists of multiple lines. Each line is one of the following:

  • A floating-point number (which may be positive or negative), representing a transaction.
  • The string \(\text{END}\), indicating the end of the current day.

The input is terminated by the end-of-file (EOF).

outputFormat

Output a single integer on a line by itself, representing the 1-indexed day with the highest profit.

## sample
500.0
-200.0
300.0
END
100.0
-50.0
100.0
END
200.0
-100.0
-50.0
END
1