Submission #851498

#TimeUsernameProblemLanguageResultExecution timeMemory
851498owoovoPassport (JOI23_passport)C++14
0 / 100
2039 ms348 KiB
#include<bits/stdc++.h> using namespace std; int bit[200010],n,qu; void mo(int pos,int x){ while(pos<=n){ bit[pos]=max(bit[pos],x); pos+=pos&(-pos); } return; } int q(int pos){ int ans=0; while(pos){ ans=max(ans,bit[pos]); pos+=pos&(-pos); } return ans; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cin>>n; for(int i=1;i<=n;i++){ int a,b; cin>>a>>b; mo(i,b); } cin>>qu; int ans=0,now=1; while(now!=n){ ans++; int x=q(now); if(x==now){ cout<<"-1\n"; return 0; } now=q(now); } cout<<ans<<"\n"; 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...