Submission #793683

#TimeUsernameProblemLanguageResultExecution timeMemory
793683vjudge1Passport (JOI23_passport)C++14
6 / 100
34 ms1876 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...