A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight. Ever since, she tried to avoid contact with others, for fear that this secret might be noticed.

To get rid of the oddity and recover her weight, a special integer sequence is needed. Hitagi's sequence has been broken for a long time, but now Kaiki provides an opportunity.

Hitagi's sequence a has a length of n. Lost elements in it are denoted by zeros. Kaiki provides another sequence b, whose length k equals the number of lost elements in a (i.e. the number of zeros). Hitagi is to replace each zero in a with an element from b so that each element in b should be used exactly once. Hitagi knows, however, that, apart from 0, no integer occurs in a and b more than once in total.

If the resulting sequence is not an increasing sequence, then it has the power to recover Hitagi from the oddity. You are to determine whether this is possible, or Kaiki's sequence is just another fake. In other words, you should detect whether it is possible to replace each zero in a with an integer from b so that each integer from b is used exactly once, and the resulting sequence is not increasing.

Input

The first line of input contains two space-separated positive integers n (2 ≤ n ≤ 100) and k (1 ≤ k ≤ n) — the lengths of sequence a and brespectively.

The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 200) — Hitagi's broken sequence with exactly k zero elements.

The third line contains k space-separated integers b1, b2, ..., bk (1 ≤ bi ≤ 200) — the elements to fill into Hitagi's sequence.

Input guarantees that apart from 0, no integer occurs in a and b more than once in total.

Output

Output "Yes" if it's possible to replace zeros in a with elements in b and make the resulting sequence not increasing, and "No" otherwise.

Examples
input
4 2
11 0 0 14
5 4
output
Yes
input
6 1
2 3 0 8 9 10
5
output
No
input
4 1
8 94 0 4
89
output
Yes
input
7 7
0 0 0 0 0 0 0
1 2 3 4 5 6 7
output
Yes
Note

In the first sample:

  • Sequence a is 11, 0, 0, 14.
  • Two of the elements are lost, and the candidates in b are 5 and 4.
  • There are two possible resulting sequences: 11, 5, 4, 14 and 11, 4, 5, 14, both of which fulfill the requirements. Thus the answer is "Yes".

In the second sample, the only possible resulting sequence is 2, 3, 5, 8, 9, 10, which is an increasing sequence and therefore invalid.

题解:实际上如果m>1的或就直接输出yes,不要想太多,因为已经保证每个数字只出现一遍,而如果m>1的话,b中的数就必定有大小关系,所以直接输出yes。

这样一来m就只能为1了,把b放进a判断一下是否递增就可以了。

 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
const int N=;
const int mod=1e9+;
int a[],b[];
int n,m,cnt;
int main()
{
int i,j;
scanf("%d%d",&n,&m);
for(i=;i<=n;i++){
scanf("%d",&a[i]);
if(a[i]==)cnt=i;
}
for(i=;i<=m;i++)
scanf("%d",&b[i]);
if(m>){
cout<<"Yes";
return ;
}
i=cnt;
a[i]=b[];
for(i=;i<=n;i++){
if(a[i]<a[i-]){
cout<<"Yes";
return ;
}
}
cout<<"No";
return ;
}

Codeforce 814A - An abandoned sentiment from past (贪心)的更多相关文章

  1. An abandoned sentiment from past

    An abandoned sentiment from past time limit per test 1 second memory limit per test 256 megabytes in ...

  2. Codeforces Round #418 (Div. 2) A+B+C!

    终判才知道自己失了智.本场据说是chinese专场,可是请允许我吐槽一下题意! A. An abandoned sentiment from past shabi贪心手残for循环边界写错了竟然还过了 ...

  3. codeforces round 418 div2 补题 CF 814 A-E

    A An abandoned sentiment from past 水题 #include<bits/stdc++.h> using namespace std; int a[300], ...

  4. 冬训 day2

    模拟枚举... A - New Year and Buggy Bot(http://codeforces.com/problemset/problem/908/B) 暴力枚举即可,但是直接手动暴力会非 ...

  5. Codeforce 835B - The number on the board (贪心)

    Some natural number was written on the board. Its sum of digits was not less than k. But you were di ...

  6. codeforce Gym 100685E Epic Fail of a Genie(MaximumProduction 贪心)

    题意:给出一堆元素,求一个子集,使子集的乘积最大,如有多个,应该使子集元素个数尽量小. 题解:贪心,如果有大于1的正数,那么是一定要选的,注意负数也可能凑出大于1的正数,那么将绝对值大于1的负数两两配 ...

  7. codeforce 810B Summer sell-off (贪心 排序)

    题意: 商店准备用n天售货(每天的货物都是一样的),第i天会卖ki件货物,并且会有li个顾客来买. 如果货物没卖完, 那么每个顾客一定会买一件. 如果货物有剩, 不会保存到第二天. 现在给定一个f, ...

  8. Codeforce 1255 Round #601 (Div. 2) A. Changing Volume (贪心)

    Bob watches TV every day. He always sets the volume of his TV to bb. However, today he is angry to f ...

  9. Codeforce 140C (贪心+优先队列)补题

    C. New Year Snowmen time limit per test2 seconds memory limit per test256 megabytes inputstandard in ...

随机推荐

  1. python3安装PIL提示Could not find a version that satisfies the requirement pil

    python3安装PIL提示如下错误,安装指令是pip3 install PIL,这个是因为PIL(Python Imaging Library)是Python中一个强大的图像处理库,但目前其只支持到 ...

  2. finecms如何调用多个指定栏目的内容

    想调用finecms多个栏目的内容,用英文状态下的逗号来分开多个id实现不了(catid=1,2,3),要如何写噢?后面ytkah想想这个跟sql语法有点一样,用IN_catid = 1,2,3果然成 ...

  3. Redis基本管理

    Redis介绍 开源 内存存储 数据结构存储  1.字符串(数字)    2.列表    3.hash    4.set 集合   5.sorted set 有序集合 用途 :数据库  缓存  消息队 ...

  4. file相关方法

    File文件,getAbsolutePath方法 public String getAbsolutePath() 该方法的作用是获得当前文件或文件夹的绝对路径.例如c:\test\1.t则返回c:\t ...

  5. python基础入门--input标签、变量、数字类型、列表、字符串、字典、索引值、bool值、占位符格式输出

    # 在python3 中: # nian=input('>>:') #请输入什么类型的值,都成字符串类型# print(type(nian)) # a = 2**64# print(typ ...

  6. mysql数据具体操作

    1.建表操作 前面提到的是简单的建表,这里需要提到一下外键. create table userinfo2( id int auto_increment primary key, name ), ge ...

  7. Golang--Hello World

    //1)go语言以包作为管理单位 //2)每个文件必须先声明包 //3)程序必须有一个main包 package main import "fmt" //入口函数 func mai ...

  8. [LeetCode] 434. Number of Segments in a String_Easy

    Count the number of segments in a string, where a segment is defined to be a contiguous sequence of ...

  9. [LeetCode] 577. Employee Bonus_Easy tag: SQL

    Select all employee's name and bonus whose bonus is < 1000. Table:Employee +-------+--------+---- ...

  10. Util.FSUtils: Waiting for dfs to exit safe mode

    有好几次,启动Hadoop和HBase之后,执行jps命令,已经看到有HMaster的进程, 但是进入到HBase的shell,执行一个命令,会出现下面的错误: ERROR: org.apache.h ...