【Codeforces 639A】Bear and Displayed Friends
【链接】 我是链接,点我呀:)
【题意】
【题解】
时刻维护一下前K大的数字就好。
因为k
【代码】
#include <bits/stdc++.h>
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define LL long long
using namespace std;
const int N = 15e4;
int n,k,q;
int temp[10],a[N+10],cnt;
int main()
{
//freopen("D:\\rush.txt","r",stdin);
scanf("%d%d%d",&n,&k,&q);
rep1(i,1,n) scanf("%d",&a[i]);
rep1(i,1,q){
int ope,id;
scanf("%d%d",&ope,&id);
if (ope==1){
int idx = -1;
rep2(j,k,1)
if (a[id]>temp[j])
idx = j;
if (idx==-1) continue;
rep2(j,k,idx+1) temp[j] = temp[j-1];
temp[idx] = a[id];
}else{
bool fi = false;
rep1(j,1,k)
if(a[id]==temp[j]){
fi = true;
break;
}
if (fi){
puts("YES");
}else{
puts("NO");
}
}
}
return 0;
}
【Codeforces 639A】Bear and Displayed Friends的更多相关文章
- 【32.89%】【codeforces 574D】Bear and Blocks
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 791D】 Bear and Tree Jumps
[题目链接]:http://codeforces.com/contest/791/problem/D [题意] 你可以从树上的节点一次最多走k条边. (称为跳一次); 树为无权树; 然后问你任意两点之 ...
- 【codeforces 791C】Bear and Different Names
[题目链接]:http://codeforces.com/contest/791/problem/C [题意] 给你n-k+1个限制 要求 a[i]..a[i]+k-1里面有相同的元素,或全都不同; ...
- 【codeforces 791B】Bear and Friendship Condition
[题目链接]:http://codeforces.com/contest/791/problem/B [题意] 给你m对朋友关系; 如果x-y是朋友,y-z是朋友 要求x-z也是朋友. 问你所给的图是 ...
- 【codeforces 791A】Bear and Big Brother
[题目链接]:http://codeforces.com/contest/791/problem/A [题意] 给你两个数字a和b; a每次乘3,b每次乘2 问你什么时候a第一次大于b [题解] 傻逼 ...
- 【19.05%】【codeforces 680D】Bear and Tower of Cubes
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【Codeforces 385C】Bear and Prime Numbers
[链接] 我是链接,点我呀:) [题意] f[i]表示在x[]中有多少个数字是i的倍数 让你求出sum(f[i]) li<=i<=ri 且i是质数 [题解] 做筛法求素数的时候顺便把素数i ...
- 【Codeforces 639B】Bear and Forgotten Tree 3
[链接] 我是链接,点我呀:) [题意] [题解] 首先,因为高度是h 所以肯定1下面有连续的h个点依次连成一条链.->用了h+1个点了 然后,考虑d这个约束. 会发现,形成d的这个路径,它一定 ...
- 【CodeForces 574B】Bear and Three Musketeers
[链接] 我是链接,点我呀:) [题意] [题解] 枚举每一条边(x,y) 然后再枚举y的出度z 看看g[x][z]是否等于1(表示联通) 如果等于1就说明找到了一个三元环,则尝试用它们的出度和-6更 ...
随机推荐
- iOS 基础类解析 - NSString、NSMutableString
iOS 基础类解析 - NSString 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 ...
- JSONObject.toBean() data转换
//toBean方法不识别date属性 要把VO的DATE该成UTIL包下的DATE 然后加上下面的代码.不然会报错JSONUtils.getMorpherRegistry().registerMo ...
- RK摄像头移植【转】
本文转载自:http://wiki.t-firefly.com/index.php/Firefly-RK3288/Camera 板载资源 Firefly-RK3288 开发板带有一个 MIPI 摄像头 ...
- STL 集合部分操作
3.28更新 在EOJ 1641 集合栈计算机中,使用并集和补集时候,第五个参数使用x.begin()会报错:assignment of read-only location,而使用inserter( ...
- Anaconda/kickstart
http://fedoraproject.org/wiki/Anaconda/Kickstart/zh-cn
- springboot 的一般配置
import javax.servlet.Filter; import org.springframework.boot.SpringApplication; import org.springfra ...
- spring jdbc、事务(三)
spring整合jdbc spring中提供了一个可以操作数据库的对象(JDBCTemplate),对象封装了jdbc技术. 1.使用spring整合jdbc需要jdbc驱动.c3p0连接池.spri ...
- CSS自定义消息提示
1.效果 2.源码 <%@ page contentType="text/html;charset=UTF-8" language="java" %> ...
- (转)vuex2.0 基本使用(1) --- state
Vuex 的核心是 store, 它是一个通过 Vuex.Store 构造函数生成的对象.为什么它会是核心呢?因为我们调用这个构造函数创建store 对象的时候,给它传递参数中包装了state, mu ...
- php数据库增删改查
首先建立一个数据库db_0808,将db_0808中表格student导入网页. CURD.php <!DOCTYPE html> <html lang="en" ...