CodeForces 450A 队列】的更多相关文章

Description There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th child wants to get at least ai candies. Jzzhu asks children to line up. Initially, the i-th child sta…
题目:这里 题意:n个app,q个操作,当操作数type为1的时候表示y这个app推送了你一条消息,当操作数type为2的时候表示将y这个app已推送的所有消息都读完,当操作数为3的时候 表示将已经推送的前(按推送的时间顺序)y条消息再读一遍(不管这前y条消息中有没有读过的,都再读一遍),问每次操作的时候的未读的消息数是多少? 用队列来模拟就好,记得每次要输出的是所有app的没有读过的消息的总数就行,不要想的太细,把读过的标记一下就行,总是觉得这个会超时,但是一想这才是2的第三题,1 的第一题,…
B. Ancient Berland Hieroglyphs 题目连接: http://codeforces.com/problemset/problem/164/B Descriptionww.co Polycarpus enjoys studying Berland hieroglyphs. Once Polycarp got hold of two ancient Berland pictures, on each of which was drawn a circle of hierog…
B. Psychos in a Line Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/319/B Description There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who h…
CodeForces 546C Soldier and Cards Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u   Description Two bored soldiers are playing card war. Their card deck consists of exactly n cards, numbered from 1 to n, all values are d…
题目链接: http://codeforces.com/contest/6/problem/E E. Exposition time limit per test 1.5 secondsmemory limit per test 64 megabytes 问题描述 There are several days left before the fiftieth birthday of a famous Berland's writer Berlbury. In this connection th…
题目链接:http://codeforces.com/problemset/problem/455/A 题目大意:有n个数,每次可以选择删除一个值为x的数,然后值为x-1,x+1的数也都会被删除,你可以获得分值x,求出能获得的最大分值为多少. 解题思路:从小到大排序,去重一下, 用cnt[i]记录一下数字i出现次数.那么可以得到状态转移方程:dp[i]=max(dp[i],dp[j]+cnt[i]*a[i])(j<i&&a[i]-a[j]>1),再用单调队列优化一下就行了O(∩…
题目链接:http://codeforces.com/problemset/problem/546/C 题解: 用两个队列模拟过程就可以了. 特殊的地方是:1.如果等大,那么两张牌都丢弃 : 2.如果操作了很多次仍不能分出胜负,则认为平手.(至于多少次,我也不知道,只能写大一点碰运气,但要防止超时) 代码如下: #include<iostream>//C - Soldier and Cards #include<cstdio> #include<cstring> #in…
题目链接:http://codeforces.com/problemset/problem/1029/B 题目大意:从数组a中选出一些数组成数组b,要求 b[i+1]<=b[i]*2 . 一开始想到的是O(n^2)的动态规划,但是超时了,下面是超时的代码. #include <iostream> using namespace std; const int maxn = 200020; int n, a[maxn], f[maxn], res = 0; int main() { cin…
Codeforces 940 E.Cashback 题意:一组数,要分为若干个区间,每个区间长度为ki(1<=ki<=n),并且对于每个区间删去前ki/c(向下取整)个小的数(即对区间升序排序后的前ki/c个数),要求找出最佳的划分方案使所有最终数组的和最小 思路:通过观察和分析 ①一个长度2*c的区间总是不会优于把它划分成两个长度为c的区间 ②在一个长度为c的区间后面添不超过c个数,都不会使删掉的数之和变大,还可能更小. 因此得到dp状态与转移方程: dp[i]:前i个数最大可删掉数之和 d…