An abandoned sentiment from past
time limit per test 1 second
memory limit per test 256 megabytes
input standard input
output standard output

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 kequals 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 aand b respectively.

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<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<queue>
#include<ctime>
#include<stack>
#include<vector>
using namespace std;
int a[],b[];
int n,m,cnt;
bool cmp(const int a,const int b)
{
return a>b;
}
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 ;
}

An abandoned sentiment from past的更多相关文章

  1. Codeforce 814A - An abandoned sentiment from past (贪心)

    A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight. Ever since ...

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

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

  3. 冬训 day2

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

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

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

  5. Sentiment Analysis resources

    Wikipedia: Sentiment analysis (also known as opinion mining) refers to the use of natural language p ...

  6. Stanford NLP学习笔记:7. 情感分析(Sentiment)

    1. 什么是情感分析(别名:观点提取,主题分析,情感挖掘...) 应用: 1)正面VS负面的影评(影片分类问题) 2)产品/品牌评价: Google产品搜索 3)twitter情感预测股票市场行情/消 ...

  7. The web application [] appears to have started a thread named [Abandoned connection cleanup thread] com.mysql.jdbc.AbandonedConnectionCleanupThread

    01-Jul-2016 14:25:30.937 WARNING [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoade ...

  8. 最小生成树 kruskal hdu 5723 Abandoned country

    题目链接:hdu 5723 Abandoned country 题目大意:N个点,M条边:先构成一棵最小生成树,然后这个最小生成树上求任意两点之间的路径长度和,并求期望 /************** ...

  9. HDU 5723 Abandoned country(落后渣国)

    HDU 5723 Abandoned country(落后渣国) Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 ...

随机推荐

  1. CoreCRM 开发实录 —— 前后端分离的重构

    虽然2月初就回来了,可 CoreCRM 一直到5月才开始恢复开发,期间是各种生活中的意外和不方便. 1. 为什么要重构 首先是一件很值得高兴的事情:CoreCRM 有了第一位 contributor! ...

  2. 'k1': 大于66的所有值, 'k2': 小于66的所有值

    #!/usr/bin/env python # -*- coding: utf-8 -*- #有如下值集合 [11,22,33,44,55,66,77,88,99,90...],将所有大于 66 的值 ...

  3. EmpyoyeeManger_1.0

    整体结构 首先创建一个名为employee的数据库 create database employee; 然后在该数据库下建一张表 CREATE TABLE t_emp( id BIGINT PRIMA ...

  4. SMP-1

    项目:该项目是用web做一个捐款的管理系统. 目标:可以记录接受捐款和资助捐款的信息,可以查询捐款等. 计划时间:2016-01-01至2016-01-15 实际用时:2016-01-08至2016- ...

  5. HttpClient和 HtmlParser实现爬虫

    网络爬虫技术 1       什么叫网络爬虫 网络爬虫(又被称为网页蜘蛛,网络机器人,在FOAF社区中间,更经常的称为网页追逐者),是一种按照一定的规则,自动地抓取万维网信息的程序或者脚本.另外一些不 ...

  6. 关于股票最佳买卖时机的lintcode代码

    class Solution {public:    /**     * @param prices: Given an integer array     * @return: Maximum pr ...

  7. redis中键的生存时间(expire)

    1.redis中可以使用expire命令设置一个键的生存时间,到时间后redis会自动删除它 expire 设置生存时间(单位/秒) pexpire 设置生存时间(单位/毫秒) ttl/pttl 查看 ...

  8. Centos6.5安装memcached

    1.检查libevent 首先检查系统中是否安装了libevent(Memcache用到了libevent这个库用于Socket的处理). # rpm -q libevent libevent-1.4 ...

  9. Linux系统档案与文件系统的压缩与打包

    以下文章基于centos6.5 文章引自:http://www.jb51.net/LINUXjishu/105916.html 一.Linux下常见的压缩指令 在linux的环境中,压缩文件的扩展名大 ...

  10. servlet的执行原理与生命周期

    先从servlet容器说起:大家最为熟悉的servlet容器就是Tomcat ,Servlet 容器是如何管理 Servlet?先看一下tomcat的容器模型:从上图可以看出 Tomcat 的容器分为 ...