479C. Exams - Codeforces Solution C++

  Problem Link : 479C. Exams 


✅ C++ Solution :

 
#include<bits/stdc++.h>
using namespace std;

#define ll long long int

int main()
{
	int n;
	cin>>n;
	pair<ll,ll> arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i].first>>arr[i].second;

	sort(arr,arr+n);

	ll curr=-1;
	for(int i=0;i<n;i++)
	{
		if(arr[i].second >= curr )
			curr = arr[i].second;
		else
			curr = arr[i].first;
	}

	cout<<curr;

}

 

Thank you for your patience reading. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Whatsapp or Facebook. 

😇Happy Learning!!