Блог пользователя Junaki

Автор Junaki, история, 7 лет назад, По-английски

/*** 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; }

  • Проголосовать: нравится
  • -23
  • Проголосовать: не нравится

»
7 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

You can use the Submission item in the rightmost menu of the blog editor to include the link of the submitted code as follows 51954067. This should make the blog more readable than copying-and-pasting the submitted code in plain-text format to the blog. You can also use the Problem item in the same menu to include the link of the problem in the blog as follows 1140A - Detective Book.