loj #6090. 「Codeforces Round #418」尘封思绪

https://loj.ac/problem/6090

 1 #include<algorithm>
 2 #include<iostream>
 3 #include<cstring>
 4 #include<cstdio>
 5 #include<cmath>
 6 #include<queue>
 7 using namespace std;
 8 #define maxn 10900
 9 int n,k,a[maxn],b[maxn],cnt;
10 char ch;
11 inline void read(int &now)
12 {
13     int f=1; ch=getchar(); now=0;
14     while(ch>'9'||ch<'0') {if(ch=='-') f*=-1; ch=getchar();}
15     while(ch>='0'&&ch<='9') now=now*10+ch-'0',ch=getchar();
16     now*=f;
17 }
18 bool cmp(int a,int b){return a>b;}
19 int main()
20 {
21     read(n); read(k);
22     for(int i=1;i<=n;i++) read(a[i]);
23     for(int i=1;i<=k;i++) read(b[i]);
24     sort(b+1,b+k+1,cmp);
25     if(b[1]<a[1])
26     {
27         printf("Yes
");
28         return 0;
29     }
30     for(int i=1;i<=n;i++)
31     {
32         if(a[i]==0)
33         {
34             a[i]=b[++cnt];
35             if(i!=n)
36             {
37                 if(b[cnt]>a[i+1]||b[cnt]<a[i-1])
38                 {
39                     printf("Yes
");
40                     return 0;
41                 }
42             }
43         }
44         if(a[i]<a[i-1])
45         {
46             printf("Yes
");
47             return 0;
48         }
49     }
50     printf("No
");
51     return 0;
52 }
View Code
原文地址:https://www.cnblogs.com/chen74123/p/7477844.html