PROBLEM LINK -
Author and Editoriallist - AmirReza PoorAkhavan
Tester - MohammadSina Pakseresht
Second Tester - Shayan CheshmJahan
Given a list of N + 1 numbers, N mixed up with them, find the maximum number between this N numbers.
Let A be the original list of size N. The number N was added in this list. Let the updated list be B. We can find the list A from the list B by finding any occurrence of the number N and deleting it. Finding maximum in a list can be done by iterating over its elements in linear time.
Parsing the input into a list of integers
For reading a line from standard input, you can use
, it will read a line and save it in string s.
You can parse the input string into integers as follows. Use [string stream], read a line by
and put it into some stringstream, then read ints one by one until it has some. You can check if it has some using
ss >> a
, it will return false if nothing is remained in stringstream (see my code for better understanding). **IMPLEMENTATION** - Setter's code - [here] (using getline and stringstream). Tester's code - [here] (using getline and parsing the input manually). Second tester's code - [here] (using getline and parsing the input manually). : http://www.codechef.com/download/Solutions/LTIME50/Setter/LOSTMAX.cpp : http://www.codechef.com/download/Solutions/LTIME50/Tester1/LOSTMAX.cpp : http://www.codechef.com/download/Solutions/LTIME50/Tester2/LOSTMAX.cpp : http://www.cplusplus.com/reference/sstream/stringstream/