Movie Festival CSES problem set solution - Problem statement- Time limit: 1.00 s Memory limit: 512 MB In a movie festival n n movies will be shown. You know the starting and ending time of each movie. What is the maximum number of movies you can watch entirely? Input The first input line has an integer n n : the number of movies. After this, there are n n lines that describe the movies. Each line has two integers a a and b b : the starting and ending times of a movie. Output Print one integer: the maximum number of movies. Constraints 1 ≤ n ≤ 2 ⋅ 10 5 1 ≤ n ≤ 2 ⋅ 10 5 1 ≤ a < b ≤ 10 9 1 ≤ a < b ≤ 10 9 Example Input: 3 3 5 4 9 5 8 Output: 2 Solution - Step -1 take input in a vector as a pair first element is ending time ans second element is starting time Step -2 sort the vector in increasing order because we will watch that movie which is ending first. Step -3 iterate over vector and calculate ans . follow code below-
Technical Keeda is best plateform for learning coding, Programming,competitive programming ,c++ language. Here we Provide best explaination of Programming question also Here You can boost your technical knowledge.You Will get aware of latest technology available in market.