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. Problem F: 多少个最大值?

    Description 输入若干个int类型的整数,求它们的最大值及其个数. Input 输入 若干个int类型的整数,至文件尾为止. Output 输出只有一行:There are # maximu ...

  2. Linux网络中接收 "二进制" 流的那些事 --- 就recv的返回值和strlen库函数进行对话

    1.    前言 很多朋友在做网络编程开发的时候可能都遇到这样的问题,在进行接收二进制流的数据的时候,使用strlen库函数来得到 二进制数据长度的时候并不准确.为什么呢??首先,使用strlen进行 ...

  3. oracle数据库热备中的备份和恢复及例子

    手工热备(开库状态) 备份控制文件: alter database backup controlfile to '/u01/oradata/prod/con.bak1'; 备份数据文件(这里用到pl/ ...

  4. c#3.0提供的扩展方法

    在c#3.0之前,想要为内置的类型添加一个方法显然是不可能的.但是,c#3.0提供的扩展方法可以解决这个问题.具体代码如下: public static class ExtendedClass {pu ...

  5. 初生牛犊不怕虎 golang入坑系列

    读前必读,下面所有内容都是来自这里. 放到这里的目的,就是为了比对一下,哪里的读者多.平心而论,同样的Markdown,博客园排版真心X看,怎么瞅怎么X看.(X := '难' || X :='耐' | ...

  6. Python之argparse模块

    argparse 命令行参数解析模块,原optparse已经停止开发,建议替换为argparse 在python2.7后默认加入 parser ArgumentParser默认解析来源sys.argv ...

  7. 整合springboot(app后台框架搭建四)

    springboot可以说是为了适用SOA服务出现,一方面,极大的简便了配置,加速了开发速度:第二方面,也是一个嵌入式的web服务,通过jar包运行就是一个web服务: 还有提供了很多metric,i ...

  8. javascript函数式编程(一)

    一.引言 javascript函数式编程在最近两年来频繁的出现在大众的视野,越来越多的框架(react,angular,vue等)标榜自己使用了函数式编程的特性,好像一旦跟函数式编程沾边,就很高大上一 ...

  9. JavaScript学习笔记(六)——Map、Set与iterable

    在学习廖雪峰前辈的JavaScript教程中,遇到了一些需要注意的点,因此作为学习笔记列出来,提醒自己注意! 如果大家有需要,欢迎访问前辈的博客https://www.liaoxuefeng.com/ ...

  10. linux 安装nginx 详解

    1 nginx安装环境 nginx是C语言开发,建议在linux上运行,本教程使用Centos6.5作为安装环境. n gcc 安装nginx需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没 ...