【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更 ...
随机推荐
- DM8168 IPNC Boa移植
1.交叉编译openssL 下载openssL-1.0.0.tar.gz在虚拟机下进行交叉编译,生成libcrypto.a及libssl.a.将这两个文件复制到DVRRDK_03.00.00.00/b ...
- 人见人爱A+B(杭电2033)
/*人见人爱A+B Problem Description HDOJ上面已经有10来道A+B的题目了,相信这些题目以前是大家的最爱,希望今天的这个A+B能给大家带来好运.也希望这个题目能唤起大家对AC ...
- 关于FrameBuffer【转】
本文转载自:http://blog.csdn.net/ganxingming/article/details/764482 一.FrameBuffer的原理 FrameBuffer 是出现在 2.2. ...
- Codeforces--630J--Divisibility(公倍数)
J - Divisibility Crawling in process... Crawling failed Time Limit:500MS Memory Limit:65536KB ...
- 【BZOJ 3620】 似乎在梦中见过的样子
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=3620 [算法] KMP [代码] #include<bits/stdc++.h ...
- hash哈希
我复习的时候,突然发现没写过hash算法,惊讶!!!赶紧补一下. 把字符串看成base进制的数.Hash值比较就是为了判断是否有相同的字符串.(base是自己定义的大于26的质数,个人认为大一点比较好 ...
- centos7 二次封装定制
- 第2章 安装Nodejs 2-4 Linux下安装Nodejs
linux下编译安装Nodejs GCC和G++分别是GNU的C和C++编译器.它们在执行编译工作的时候把源代码通过预处理转化成汇编语言生成.i后缀的文件,再由汇编变成目标机器代码,最后连接目标代码 ...
- 机器人走迷宫(dfs)
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1590 #include <stdio.h ...
- Beta冲刺-星期三
这个作业属于哪个课程 <课程的链接> 这个作业要求在哪里 <作业要求的链接> 团队名称 Three cobblers 这个作业的目标 剩余任务预估,分配 ...