[暴力]JZOJ 5891 巡逻

Description

 

Input

Output

 

Sample Input

7 4
6
4
2
1

Sample Output

3
5
6
4
2
1
7
 

Data Constraint

分析

水题不解释

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N=1e5+10;
int a[N],b[N],at,bt;
int n,m;

int main() {
    freopen("patrol.in","r",stdin);
    freopen("patrol.out","w",stdout);
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++) a[i]=i;
    for (int i=1;i<=m;i++) {
        scanf("%d",&b[i]);
        a[b[i]]=2147483647;
    }
    sort(a+1,a+n+1);
    at=1;bt=1;
    for (int i=1;i<=n;i++) {
        while (a[at]>b[bt]&&bt<=m) {
            printf("%d\n",b[bt]);
            bt++;i++;
        }
        if (i>n) break;
        printf("%d\n",a[at]);
        at++;
    }
    fclose(stdin);fclose(stdout);
}
View Code

猜你喜欢

转载自www.cnblogs.com/mastervan/p/9787836.html