hihoCoder太阁最新面经算法竞赛12 register

Ended

Participants:164

Verdict:Accepted
Score:100 / 100
Submitted:2016-10-24 10:13:42

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
25
26
27
28
29
30
31
#include<stdio.h>
#include<string.h>
#include<stack>
#include<math.h>
#include<algorithm>
using namespace std;
const int N=100000+10;
int a[N];
int b[N];
void solve()
{
    int i,j,n;
    scanf("%d", &n);
    for(i=0;i<n;i++)
    {
        scanf("%d", a+i);
        b[i]=a[i];
    }
    sort(b, b+n);
    int mi=n, ma=-1;
    
    for(i=0;i<n;i++)
    {
        if(b[i]!=a[i])
        {
            mi=min(i, mi);
            ma=max(i, ma);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX