[链接]:CF/4892 [题意]: 一个人解决n个问题,这个问题的值比k小, 每次只能解决最左边的或者最右边的问题 解决了就消失了.问这个人能解决多少个问题. [代码]: #include<bits/stdc++.h> #define PI acos(-1.0) #define pb push_back #define F first #define S second #define debug puts #define setp cout << fixed << s…
Mishka started participating in a programming contest. There are nn problems in the contest. Mishka's problem-solving skill is equal to kk. Mishka arranges all problems from the contest into a list. Because of his weird principles, Mishka only solves…
Maxim wants to buy some games at the local game shop. There are n games in the shop, the i-th game costs ci. Maxim has a wallet which can be represented as an array of integers. His wallet contains m bills, the j-th bill has value aj. Games in the sh…
cf 443 D. Teams Formation(细节模拟题) 题意: 给出一个长为\(n\)的序列,重复\(m\)次形成一个新的序列,动态消除所有k个连续相同的数字,问最后会剩下多少个数(题目保证消除的顺序对答案不会造成影响) \(n <= 10^{5} ,m <= 10^{9} ,k <= 10^{9},a_i <= 10^{5}\) 思路: 直接上题解好了 首先要用栈预处理序列本身,然后考虑处理后的序列 比较头和尾是否能够消除,细节需要处理好. #include<bi…
https://codeforces.com/contest/1121/problem/D 题意 给你一个m(<=5e5)个数的序列,选择删除某些数,使得剩下的数按每组k个数以此分成n组(n*k<=m),存在只要一组满足和目标集合s(|s|<=k)匹配(即集合中存在的数,组内一定存在) 题解 重点:找出至少一组满足要求的数 假设[l,r]内满足要求,还需要满足:\((l-1)/k*k+(m-r)/k*k>=k*(n-1)\),可以用双指针,对于每个l可以处理出最小的r满足要求 这样…
题目链接:http://codeforces.com/problemset/problem/676/B 题意:一个n层的平面酒杯金字塔,如图,每个杯子的容量相同.现在往最顶部的一个杯子倒 t 杯酒,求流动结束后有多少个杯子被装满. 思路:每个局部的两代三个杯子的流动过程是一致的,因此可以用递归来模拟求解. 具体为:设add(cur, i, l)执行“往第 i 个杯子倒cur量的酒”,附加信息: i 位于第 l 层.若执行完剩余了surplus量的酒,则往 i 的下一层左右两侧的杯子各倒surpl…
Description 小Q同学在学习操作系统中内存管理的一种页面置换算法,LRU(LeastRecentlyUsed)算法. 为了帮助小Q同学理解这种算法,你需要在这道题中实现这种算法,接下来简要地介绍这种算法的原理: 1.初始化时,你有一个最大长度为n的空队列,用于暂时存储一些页面的地址. 2.当系统需要加载一个不在队列中的页面时,如果队列已满,则弹出队首元素,并将需要加载的页面加到队尾, 否则直接将需要加载的页面加到队尾. 3.当系统需要加载一个在队列中的页面时,将该页面移至队尾. 在这道…
题目链接:https://www.nowcoder.com/acm/contest/144/A 标题:A.Singing Contest | 时间限制:1 秒 | 内存限制:256M Jigglypuff is holding a singing contest. There are 2n singers indexed from 1 to 2n participating in the contest. The rule of this contest is like the knockout…
H - A + B Strikes Back A + B is often used as an example of the easiest problem possible to show some contest platform. However, some scientists have observed that sometimes this problem is not so easy to get accepted. Want to try? Input The input co…
http://codeforces.com/contest/369/problem/B 先对k个处理,先处理sk%k个为sk/k+1,如果sk/k==0,k个数都为sk/k:对与剩下的数也按照同样的方法处理,处理完之后就是所要求的序列. #include <cstdio> #include <cstring> #include <algorithm> #define maxn 10000 using namespace std; int n,k,l,r,s1,s2; i…