思路: 对于small数据,由于求和及奇数数量两个限制条件均满足区间单调性,可以直接使用尺取法(滑动窗口法)求解. 对于large数据,奇数数量依然是满足区间单调性的.首先使用尺取法,找到所有满足奇数限制条件的区间,然后对于每个区间分别计算不超过D的最大连续子段和.具体来说,可将区间的所有前缀和放到一个multiset中,二分查找即可. 实现: #include <bits/stdc++.h> using namespace std; typedef long long ll; ; const…
[题目] C. Candies Distribution [描述] n个小朋友排排坐吃糖糖,小朋友从左到右编号1到n.每个小朋友手上有一定数量的糖.对于第i个小朋友来说,编号比他小的小朋友中有li个小朋友拥有的糖比他多,编号比他大的小朋友中有ri个小朋友拥有的糖比他多.已知每个小朋友手上至少有1颗糖.最多有n颗糖,求一种可能的每个小朋友手上的糖的数量的情形,输出YES和一种情形:如果不存在这样的可能,则输出NO. 数据范围:1<=n<=1000,0<=li,ri<=n [思路] 对…
Google Kick Start Round G 2019 Book Reading 暴力,没啥好说的 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=1e5+5; int n,m,q,p[maxn],r[maxn]; int cnt[maxn]; int main() { int T,Case=1; scanf("%d",&T); while(T-…
Practice Round Problem A GBus count (9pt/15pt) (2019年1月14日,kickstart群每日一题) 题意:有一条笔直的大路,上面有城市编号从 1 开始从左到右一次排列.上面有 N 个 GBuses, 每一个 bus[i] 连接 A[i] 到 B[i] 两个地点(包含这两个地方).我们想要求 P 个城市,每个城市经过的公交车数量. 输入输出 和 数据规模 如下: There exist some cities that are built alo…
A题:给定A,N,P,计算A的N!次幂对P取模的结果. 数据范围: T次测试,1 ≤ T ≤ 100 1<=A,N,P<=105 快速幂一下就好了.O(nlogn). AC代码: #include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<=b;++i) using namespace std; const int MAXN=1e5+1e4; long long mo[MAXN]; int TT; long long a,…
Problem B. Vote A and B are the only two candidates competing in a certain election. We know from polls that exactly N voters support A, and exactly M voters support B. We also know that N is greater than M, so A will win. Voters will show up at the…