#K52187. Stock Price Trend Analysis
Stock Price Trend Analysis
Stock Price Trend Analysis
You are given a time series of stock prices corresponding to consecutive dates. Your task is to determine the price trend between consecutive days. Specifically, for each adjacent pair of days, output "UP" if the stock price increased, "DOWN" if it decreased, and "SAME" if it remained unchanged.
The input is provided via standard input (stdin) and the output should be printed to standard output (stdout). The first line of input contains an integer n which represents the number of days. The following n lines each contain a date in the format \(YYYY\text{-}\(MM\text{-}DD\)\) and an integer representing the stock price for that day.
Your solution should process the input and print the trends as a single line of text, with each trend separated by a space.
inputFormat
The first line contains an integer n denoting the number of days. Each of the following n lines contains a date in the format YYYY-MM-DD and a stock price (integer), separated by space. Input is read from standard input (stdin).
outputFormat
Print a single line containing the trend of stock prices for every consecutive pair of days. For each adjacent pair, print "UP" if the price increased, "DOWN" if it decreased, or "SAME" if the price is unchanged. Separate the outputs by a single space. Output is written to standard output (stdout).## sample
3
2023-10-01 100
2023-10-02 102
2023-10-03 104
UP UP