题目链接: B. Bear and Displayed Friends time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Limak is a little polar bear. He loves connecting with other bears via social networks. He has n friends…
[链接] 我是链接,点我呀:) [题意] [题解] 时刻维护一下前K大的数字就好. 因为k<=6 然后数字不会减少只会增加. 因此只要维护一个大小为k的数组就ok. 保证这个数组是有序的. 写个插入排序(或者sort也可以 然后询问的话就循环k次遍历就ok [代码] #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. Bear and Displayed Friends 题目连接: http://www.codeforces.com/contest/658/problem/B Description Limak is a little polar bear. He loves connecting with other bears via social networks. He has n friends and his relation with the i-th of them is describ…
题目链接: http://codeforces.com/contest/658/problem/B 题意: 给定元素编号及亲密度,每次插入一个元素,并按亲密度从大到小排序.给定若干操作,回答每次询问的元素是否排在前k个. 分析: 先附上我的垃圾做法: 之前没怎么用过set,比赛的时候第一反应就是利用优先级队列,每次将元素直接插入队列中,由于k最大为6,所以遍历队列的前k个,然后看是否有查询的元素. 代码: #include<iostream> #include<cstdio> #i…
A. Bear and Elections time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Limak is a grizzly bear who desires power and adoration. He wants to win in upcoming elections and rule over the Bearla…
优先队列模拟一下就好. #include<bits/stdc++.h> using namespace std; priority_queue<int>q; int main() { int n; scanf("%d",&n); int t; scanf("%d",&t); ; i <= n; i++){ int v; scanf("%d",&v); q.push(v); } ; while(…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Limak is a little bear who loves to play. Today he is playing by destroying block towers. He built n towers in a row. The i-th tower is made of h…
题目链接:http://codeforces.com/contest/828/problem/C 题解:有点意思的题目,可用优先队列解决一下具体看代码理解.或者用并查集或者用线段树都行. #include <iostream> #include <cstring> #include <queue> #include <vector> #include <cstdio> #include <map> #include <strin…
题目链接: C. Bear and Prime 100 time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output This is an interactive problem. In the output section below you will see the information about flushing the outpu…
题目链接: B. Bear and Finding Criminals //#include <bits/stdc++.h> #include <vector> #include <iostream> #include <queue> #include <cmath> #include <map> #include <cstring> #include <algorithm> #include <cstd…