题解 CF1005A 【Tanya and Stairways】】的更多相关文章

楼上别说这个题水,这个题可能还真有不知道的知识点. 看到这个题,想到刚学的单调栈. 单调栈? 单调栈和单调队列差不多,但是我们只用到它的栈顶. 单调,意思就是一直递增或者递减. 这跟这个题有什么关系? 我们看到这个题说: 这N个数是由M个从1开始的连续自然序列组成的 也就是说,我们求的是一些单调栈的大小. 好说!STL,上! 我们开一堆栈,当进去的序列非大于等于原先栈内的栈顶,就压进当前栈: 否则,换一个栈继续压. 然后我们用.size()挨个输出栈的大小. 这里我们可以将栈看作是一个单调的序列…
Little girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairway, she starts counting steps from 1 to the number of steps in this stairway. She speaks every number aloud. For example, if she climbs two stairways,…
Little girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairway, she starts counting steps from 11 to the number of steps in this stairway. She speaks every number aloud. For example, if she climbs two stairways…
D. Tanya and Password Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/508/problem/D Description While dad was at work, a little girl Tanya decided to play with dad's password to his secret database. Dad's password is a stri…
B. Kolya and Tanya Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/problem/B Description Kolya loves putting gnomes at the circle table and giving them coins, and Tanya loves studying triplets of gnomes, sitting in the v…
C. Tanya and Toys 题目链接http://codeforces.com/contest/659/problem/C Description In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collectio…
人生中第三次\(CF\)... 考试中切了\(A\)~\(E\) \(F\)题会做没时间写 题解 A:Points on the line 题意 给定一个数列,删最小的数,使最大差不大于一个定值 Sol 排序后选的一定是段连续的区间,枚举左右端点即可 手速慢了233 # include <bits/stdc++.h> # define RG register # define IL inline # define Fill(a, b) memset(a, b, sizeof(a)) using…
人生的大起大落莫过如此,下一场我一定要回紫. [A]Points on the line 题意: 一个直线上有\(n\)个点,要求去掉最少的点,使得最远两点距离不超过\(d\). 题解: 暴力两重for,更新答案. #include<cstdio> #include<algorithm> using namespace std; #define F(i,a,b) for(int i=(a);i<=(b);++i) int n,q,ans=0; int a[100001]; i…
C. Tanya and Toys 题目连接: http://www.codeforces.com/contest/659/problem/C Description In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new col…
Codeforces Round #540 (Div. 3) 题目链接:https://codeforces.com/contest/1118 题目太多啦,解释题意都花很多时间...还有事情要做,就选一些题来写吧. B. Tanya and Candies 题意: 在n个数中任意删去一个,如果这个数被删去后,剩余数的奇数和以及偶数和相等,那么就定义这个数为"好数".现在问这n个数中有多少个“好数”. 题解: 预处理出奇数前缀和.偶数前缀和,删去一个数后所有的奇数位置和 就为前面的奇数和…