Submission #851500

#TimeUsernameProblemLanguageResultExecution timeMemory
851500owoovoPassport (JOI23_passport)C++14
6 / 100
90 ms3600 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 x; cin>>x; 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...