A. Arrays
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

You are given two arrays A and B consisting
of integers, sorted in non-decreasing order. Check whether it is possible to choose knumbers
in array A and choose m numbers
in array B so that any number chosen in the first array is strictly less than any number chosen in the second array.

Input

The first line contains two integers nA, nB (1 ≤ nA, nB ≤ 105),
separated by a space — the sizes of arrays A and B,
correspondingly.

The second line contains two integers k and m (1 ≤ k ≤ nA, 1 ≤ m ≤ nB),
separated by a space.

The third line contains nA numbers a1, a2, ... anA ( - 109 ≤ a1 ≤ a2 ≤ ... ≤ anA ≤ 109),
separated by spaces — elements of array A.

The fourth line contains nB integers b1, b2, ... bnB ( - 109 ≤ b1 ≤ b2 ≤ ... ≤ bnB ≤ 109),
separated by spaces — elements of array B.

Output

Print "YES" (without the quotes), if you can choose k numbers
in array A and m numbers
in array B so that any number chosen in arrayA was
strictly less than any number chosen in array B. Otherwise, print "NO"
(without the quotes).

Sample test(s)
input
3 3
2 1
1 2 3
3 4 5
output
YES
input
3 3
3 3
1 2 3
3 4 5
output
NO
input
5 2
3 1
1 1 1 1 1
2 2
output
YES
Note

In the first sample test you can, for example, choose numbers 1 and 2 from array A and number 3 from array B (1
< 3 and 2 < 3).

In the second sample test the only way to choose k elements in the first array and m elements
in the second one is to choose all numbers in both arrays, but then not all the numbers chosen in A will be less than all the numbers
chosen in B.

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm> using namespace std;
int a[100100],b[100010];
int n,m;
int k,t; int main()
{
while(scanf("%d%d",&n,&m)!=EOF)
{
scanf("%d%d",&k,&t);
for(int i=0; i<n; i++)
{
scanf("%d",&a[i]);
}
for(int i=0; i<m; i++)
{
scanf("%d",&b[i]);
}
if(a[k-1] < b[m-t])
{
printf("YES\n");
}
else
{
printf("NO\n");
} }
return 0;
}

A. Arrays(Codeforces Round #317 水题)的更多相关文章

  1. Coprime Arrays CodeForces - 915G (数论水题)

    反演一下可以得到$b_i=\sum\limits_{d=1}^i{\mu(i)(\lfloor \frac{i}{d} \rfloor})^n$ 整除分块的话会T, 可以维护一个差分, 优化到$O(n ...

  2. codeforces 659A A. Round House(水题)

    题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. Educational Codeforces Round 27 补题

    题目链接:http://codeforces.com/contest/845 A. Chess Tourney 水题,排序之后判断第n个元素和n+1个元素是不是想等就可以了. #include < ...

  4. Codeforces数据结构(水题)小结

    最近在使用codeblock,所以就先刷一些水题上上手 使用codeblock遇到的问题 1.无法进行编译-------从setting中的编译器设置中配置编译器 2.建立cpp后无法调试------ ...

  5. Educational Codeforces Round 15 套题

    这套题最后一题不会,然后先放一下,最后一题应该是大数据结构题 A:求连续最长严格递增的的串,O(n)简单dp #include <cstdio> #include <cstdlib& ...

  6. CodeForces 705A Hulk (水题)

    题意:输入一个 n,让你输出一行字符串. 析:很水题,只要判定奇偶性,输出就好. 代码如下: #pragma comment(linker, "/STACK:1024000000,10240 ...

  7. Codeforces Round #346 (Div. 2) A. Round House 水题

    A. Round House 题目连接: http://www.codeforces.com/contest/659/problem/A Description Vasya lives in a ro ...

  8. Educational Codeforces Round 21 A-E题题解

    A题      ............太水就不说了,贴下代码 #include<string> #include<iostream> #include<cstring& ...

  9. Codeforces Round #317 (div 2)

    Problem A Arrays 思路:水一水. #include<bits/stdc++.h> using namespace std; ; int n1,n2,k,m,a[N],b[N ...

随机推荐

  1. Android使用百度地图定位并显示手机位置后使用前置摄像头“偷拍”

    今天老板让我验证一下技术可行性,记录下来. 需求 :定位手机的位置并在百度地图上显示,得到位置后使用前置摄像头进行抓拍 拿到这个需求后,对于摄像头的使用不太熟悉,于是我先做了定位手机并在百度地图上显示 ...

  2. Unity 游戏框架搭建 (二十) 更安全的对象池

    上篇文章介绍了,只需通过实现IObjectFactory接口和继承Pool类,就可以很方便地实现一个SimpleObjectPool.SimpleObjectPool可以满足大部分的对象池的需求.而笔 ...

  3. sublime text3添加右键打开的操作

    前一段重新安装了Sublime Text3,不过一直不在右键菜单中,所以决定添加,有如下2种方法. 方法一(推荐). 把以下代码,复制到SublimeText3的安装目录,然后重命名为:sublime ...

  4. C#实现的apache htpasswd加密

    一.VisualSvn Server 这个软件大家都知道,具体使用时创建用户名密码和组时,每次都要登陆到VisualSvn Server所在的机器上,次次如此... 由于一些原因要把这个用户管理的功能 ...

  5. 最小化安装linux CentOS_7操作系统

    实验环境为VMware虚拟机安装操作系统. 1.打开VMware Workstation 虚拟机,选择创建新的虚拟机: 2.选择linux-CentOS 64位操作系统: 3.为虚拟机命名,并选择安装 ...

  6. [转]结合HierarchyViewer和APK文件反编译获得APP元素id值

    背景: 最近在使用Robotium进行Android自动化测试.遇到了一个问题:我需要获得一个View的id(int型数值).此前我在http://maider.blog.sohu.com/25544 ...

  7. html基本标签与属性

    HTML 超文本标记语言 html5 建立一个HTML文件:文件名 . 后缀(html)   解析:就是去识别 注释:就是给开发人员开的批注------浏览器不去解析(不去输出)   HTML的整体框 ...

  8. windows配置caffe + python和matlab接口

    参考: http://blog.csdn.net/baidu_26408419/article/details/53711640 http://www.cnblogs.com/love6tao/p/5 ...

  9. Web攻防之暴力破解(何足道版)

    原创文章 原文首发我实验室公众号 猎户安全实验室 然后发在先知平台备份了一份 1 @序 攻防之初,大多为绕过既有逻辑和认证,以Getshell为节点,不管是SQL注入获得管理员数据还是XSS 获得后台 ...

  10. 变位词(0029)-swustoj

    变位词(0029)水题 变位词如果两个单词的组成字母完全相同,只是字母的排列顺序不一样,则它们就是变位词,两个单词相同也被认为是变位词.如tea 与eat , nic 与cin, ddc与dcd, a ...