A. Arrays(Codeforces Round #317 水题)
2 seconds
256 megabytes
standard input
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.
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.
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).
3 3
2 1
1 2 3
3 4 5
YES
3 3
3 3
1 2 3
3 4 5
NO
5 2
3 1
1 1 1 1 1
2 2
YES
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 水题)的更多相关文章
- Coprime Arrays CodeForces - 915G (数论水题)
反演一下可以得到$b_i=\sum\limits_{d=1}^i{\mu(i)(\lfloor \frac{i}{d} \rfloor})^n$ 整除分块的话会T, 可以维护一个差分, 优化到$O(n ...
- codeforces 659A A. Round House(水题)
题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Educational Codeforces Round 27 补题
题目链接:http://codeforces.com/contest/845 A. Chess Tourney 水题,排序之后判断第n个元素和n+1个元素是不是想等就可以了. #include < ...
- Codeforces数据结构(水题)小结
最近在使用codeblock,所以就先刷一些水题上上手 使用codeblock遇到的问题 1.无法进行编译-------从setting中的编译器设置中配置编译器 2.建立cpp后无法调试------ ...
- Educational Codeforces Round 15 套题
这套题最后一题不会,然后先放一下,最后一题应该是大数据结构题 A:求连续最长严格递增的的串,O(n)简单dp #include <cstdio> #include <cstdlib& ...
- CodeForces 705A Hulk (水题)
题意:输入一个 n,让你输出一行字符串. 析:很水题,只要判定奇偶性,输出就好. 代码如下: #pragma comment(linker, "/STACK:1024000000,10240 ...
- 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 ...
- Educational Codeforces Round 21 A-E题题解
A题 ............太水就不说了,贴下代码 #include<string> #include<iostream> #include<cstring& ...
- Codeforces Round #317 (div 2)
Problem A Arrays 思路:水一水. #include<bits/stdc++.h> using namespace std; ; int n1,n2,k,m,a[N],b[N ...
随机推荐
- 自定义Base16加密
自定义Base16加 ...
- 初始MyBatis
初始MyBatis 框架的概念: 框架是一个提供可重复的功用结构的半成品.它为我们构建新的应用程序提供了极大的便利,一方面提供了可以拿来就用的工具,更重要的是提供了可重用的设计.D 框架技术的优势: ...
- C#实现的apache htpasswd加密
一.VisualSvn Server 这个软件大家都知道,具体使用时创建用户名密码和组时,每次都要登陆到VisualSvn Server所在的机器上,次次如此... 由于一些原因要把这个用户管理的功能 ...
- 在windows上搭建镜像yum站的方法(附bat脚本)
方法一:支持rsync的网站 对于常用的centos.Ubuntu.等使用官方yum源在 http://mirrors.ustc.edu.cn 都存在镜像. 同时 http://mirrors.ust ...
- Web攻击技术
Web攻击技术 1.针对Web的攻击技术 1.1.在客户端即可篡改请求 在Web应用中,从浏览器那接收到的Http的全部内容,都可以在客户端自由地变更.篡改,所以Web应用可能会接收到与预期数据不相同 ...
- python3学习笔记(3)
一.内置函数补充1.callable()检测传递的参数是否可以被调用.def f1() pass可以被调用f2 = 123不可以被调用2.chr()和ord()chr()将ascii码转换成字符,or ...
- c#使用PortableDeviceApiLib读取便携式设备(WPD:Windows Portable Devices)信息
相关名词解释: WPD( Windows Portable Devices) 译作Windows 便携设备 (WPD) 是一种驱动程序技术,可支持广泛的可移动设备,比如移动电话.数码相机和便携媒体播放 ...
- canvas动画之动态绘出六边形
先上 demo: http://en.jsrun.net/W5iKp/show 这两天我一直在研究这个动画,花了大量的时间来想是如何实现的, 一开始我是想在进入 canvas 时按时间来用 lineT ...
- Less 原理
Less 原理 Less 包含一套自定义的语法及一个解析器,用户根据这些语法定义自己的样式规则,这些规则最终会通过解析器,编译生成对应的 CSS 文件. Less 并没有裁剪 CSS 原有的特性,更不 ...
- EntityFramework For Mysql 动态切换数据源
1.简介 在工作中遇到一个问题.项目有三个数据库(三个数据库表结构一样),用户可以选择使用哪个数据库.其实就是动态切换数据库连接. 2.EntityFramework For Mysql 先来简单的介 ...