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 ...
随机推荐
- Problem B: 开个餐馆算算账
Description 小明创业了!他开了一家餐馆,每天客人还挺多的.每天下班后,他都要算算今天总共收入多少钱,但是手工算太麻烦了,所以他来向你求助了. Input 第1行N>0,表示餐馆提供N ...
- JavaScript之数组五大迭代方法总结
ES5定义了五个迭代方法,每个方法都接收两个参数:要在每一项上运行的函数和运行该函数的作用域对象(可选的),作用域对象将影响this的值.传入这些方法中的函数会接收三个参数:数组的项的值.该项在数组中 ...
- selenium-iframe操作
iframe,又叫浮动帧标记,是内嵌的网页元素,可以将一个html文件嵌入到另一个html文件中显示. 最典型的案例就是163邮箱登录:http://mail.163.com/,被绿色覆盖的部分即为i ...
- React 和 Angular 各有什么优缺点,各自又适合什么开发场景?
最近正在学习React,便谈一点自己的浅见. Angular.js首先Angular的背后是Google,所以社区基础是不用担心的,整个生态也已经是非常的完整了,从最基本的Tutorial到Stack ...
- 如何编写通用的 Helper Class
Github: https://github.com/nzbin/snack-helper Docs: https://nzbin.github.io/snack-helper 前言 什么是 help ...
- 微软Connect(); 2017大会梳理:Azure、数据、AI开发工具
在今天召开的 Connect(); 2017 开发者大会上,微软宣布了 Azure.数据.AI 开发工具的内容.这是第一天的 Connect(); 2017 的主题演讲. 在开场视频中霍金又来了.你记 ...
- 诸葛马前课andoid app 应用
前段时间学了点安卓开发的知识,也在同时,陪家人看了<新闺蜜时代 >的后面几集,其中,周小北提到了诸葛马前课. 于是网上查了些资料,学习了一下马前课的计算方法,本着程序服务生活的原则,省去不 ...
- django实现分片上传文件
目标:利用django实现上传文件功能 1,先设置路由系统 urls.py from django.conf.urls import url,include from django.contrib i ...
- Centos6.9安装vsftpd并配置多用户的方法
本文介绍了Centos6.9安装vsftpd并配置多用户的方法,分享给大家,具体如下: 一.安装vsftpd ? 1 2 3 4 5 6 7 8 #安装vsftpd yum -y install vs ...
- vim编辑器介绍及其常用命令
vim简单的介绍 Vim 编辑器是一个模式编辑器 . 这意味着在不同状态下编辑器有不同的行为模式 . 两个基本的模式是 Normal 模式和 Insert 模式 ,还有可视模式. 在 Normal 模 ...