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. Python之数据类型-[bisect,heap]

    bisect >>> import bisect >>> >>> b = [ 20, 34, 35, 65, 78 ] >>> ...

  2. ORA-01745: 无效的主机/绑定变量名 ORA-00917: 缺失的逗号 oracle日期格式错误

    今天在oracle中执行插入语句的时候报了一个奇怪的错误,在程序中报的错误是ORA-01745: 无效的主机/绑定变量名,网上一查说是缺失逗号,在查询分析器执行的时候报缺失的逗号,仔细看了一下也没有缺 ...

  3. YII 多表联查 纵表

    A id 与B a.id B id 与C b.id C id 与D c.id 查A读D数据 应用场景: order表 ordergoods表 goods表 merchant加盟商 order 与ord ...

  4. 2)C语言的基本知识(C自考学习)

    字符集 在C语言程序中允许出现的所有基本字符的组合称为C语言的字符集.C语言的字符集就是ASCII字符集.主要包含一下几类: 1)大小写英文字母A~Z,a~z(52个) 2)数字0-9(10个) 3) ...

  5. China Azure中部署Kubernetes(K8S)集群

    目前China Azure还不支持容器服务(ACS),使用名称"az acs create --orchestrator-type Kubernetes -g zymtest -n kube ...

  6. 开源纯C#工控网关+组态软件(六)图元组件

    一.   图元概述 图元是构成人机界面的基本单元.如一个个的电机.设备.数据显示.仪表盘,都是图元.构建人机界面的过程就是铺排.挪移.定位图元的过程. 图元设计是绘图和编码的结合.因为图元不仅有显示和 ...

  7. R-CNN论文翻译

    R-CNN论文翻译 Rich feature hierarchies for accurate object detection and semantic segmentation 用于精确物体定位和 ...

  8. 在本地搭建play-with-docker

    安装play-with-docker 官方Github地址 https://github.com/play-with-docker/play-with-docker 本人Github地址 https: ...

  9. 使用ThinkPHP的扩展功能

    文件上传类的代码位于“\ThinkPHP\Libabry\Think\Uplod.class.php”,实例化电偶用即可.1:在Home模块Index控制器test方法中实现文件上传功能.打开文件\A ...

  10. HDU1532 Drainage Ditches SAP+链式前向星

    Drainage Ditches Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...