1140A Detective book

Revision en1, by Junaki, 2019-03-28 22:11:55

/*** Bismilahir Rahmanir Rahim ***/

include<bits/stdc++.h>

define sf scanf

define pf printf

define get(a) sf("%d", &a)

define get2(a,b) sf("%d %d", &a,&b)

define get3(a,b,c) sf("%d %d %d", &a, &b &a)

define get1(a) sf("%lld", &a)

define get12(a,b) sf("%lld %lld", & a,&b)

define get13(a,b,c) sf("%lld %lld %lld", &a,&b,&c)

define case(a) pf("Case %d:"a++)

define floop(a,b) for(int i=a; i<b; i++)

define rt return

using namespace std;

int n; vectora; inline bool book(){ if(!(cin>>n) )return false;

a.resize(n); for(int i=0; i<n; i++){ cin>>a[i]; a[i]--; } return true; }

inline void solve(){ int pos=0, count=0; while(pos<n){ count++;

int mx=pos;
  while(n>pos && pos<=mx){
        mx=max(mx,a[pos]);
    pos++;
  }
  }

cout<<count<<endl; } int main(){ if(book()){ solve(); } return 0; }

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Junaki 2019-03-28 22:11:55 986 Initial revision (published)