So i have almost similar approach to the editorial, where i chose the smallest feasible day for every exam and update my answer. Though i am getting RUNTIME_ERROR in test case 18.
Things i checked for: - proper data types used - dry ran my code on paper on many cases - searched for meaning of exit code -1073741819, but to no avail. still get the error.
The compiler does not show the full test case and stops in between so cannot give u the test case. But it is numbered 18 with very large values.
Here is my code:
#include<bits/stdc++.h>
using namespace std;
bool compare(pair<long long,long long> &a,pair<long long,long long> &b)
{
if(a.first<=b.first)
return true;
return false;
}
int main()
{
int n;
cin>>n;
pair<long long,long long> A[n];
long long day=0;
for(int i=0;i<n;i++)
{
long long a,b;
cin>>a>>b;
A[i]={a,b};
}
sort(A,A+n,compare);
for(int i=0;i<n;i++)
{
long long temp=LLONG_MAX;
if(day<=A[i].first)
temp=A[i].first;
if(day<=A[i].second && temp>A[i].second)
temp=A[i].second;
if(temp!=LLONG_MAX)
day=temp;
}
cout<<day;
return 0;
}
ISO C++ Standard (N4659) section 28.7:
Your
compare
violates this requirement.Check this out.