This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std ;
const int N = 2e5 ;
int n, q, l[N + 1], r[N + 1], x[N + 1] ;
int main()
{
ios_base::sync_with_stdio( 0 ) ;
cin.tie( 0 ) ;
cout.tie( 0 ) ;
cin >> n ;
for(int i = 1 ; i <= n ; i++)
cin >> l[i] >> r[i] ;
cin >> q ;
for(int i = 1 ; i <= q ; i++)
cin >> x[i] ;
if(q == 1 && x[1] == 1)
{
int ans = 0, mx = r[1], ind = 1 ;
while(ind < n)
{
int mx1 = 0 ;
for(int j = ind ; j <= mx ; j++)
mx1 = max(mx1, r[j]) ;
ans++ ;
ind = mx ;
if(mx1 == mx)
break ;
mx = max(mx1, mx) ;
}
if(ind < n)
ans = -1 ;
cout << ans ;
return 0 ;
}
return 0 ;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |