Getting runtime error in problem 479C Exams

Revision en1, by ChaituBoi, 2020-08-23 10:11:47

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; }

Tags greedy, mysterious runtime error

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English ChaituBoi 2020-08-23 10:13:41 20
en1 English ChaituBoi 2020-08-23 10:11:47 1189 Initial revision (published)