hiho week 276 register

Ended

Participants:40

Verdict:Accepted
Score:100 / 100
Submitted:2019-10-18 21:31:03

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
int a[100004];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int x;scanf("%d",&x);
        a[x]=i;
    }
    int cnt=0,p=n,last=n+1;
    while(p>=1){
        int pos=a[p];
        if(last<pos)break;
        cnt++;
        last=pos;
        p--;
    }
    printf("%d\n",n-cnt);
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX