[Usaco2015 dec]Breed Counting】的更多相关文章

4397: [Usaco2015 dec]Breed Counting Time Limit: 10 Sec  Memory Limit: 128 MB Description Farmer John's N cows, conveniently numbered 1…N, are all standing in a row (they seem to do so often that it now takes very little prompting from Farmer John to…
bzoj4397[Usaco2015 dec]Breed Counting 题意: 给定一个长度为N的序列,每个位置上的数只可能是1,2,3中的一种.有Q次询问,每次给定两个数a,b,请分别输出区间[a,b]里数字1,2,3的个数.n≤100000,q≤100000. 题解: 裸前缀和. 代码: #include <cstdio> #include <cstring> #include <algorithm> #define inc(i,j,k) for(int i=j…
原题链接https://www.lydsy.com/JudgeOnline/problem.php?id=4397 用线段树维护区间和即可.时间复杂度\(O((N+Q)logN)\). #include<iostream> #include<cstring> #include<cstdio> #define maxn 100010 using namespace std; inline int read(){ register int x(0),f(1); regist…
4397: [Usaco2015 dec]Breed Counting Time Limit: 10 Sec  Memory Limit: 128 MB Submit: 29  Solved: 25 [Submit][Status][Discuss] Description Farmer John's N cows, conveniently numbered 1-N, are all standing in a row (they seem to do so often that it now…
4390: [Usaco2015 dec]Max Flow Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 177  Solved: 113[Submit][Status][Discuss] Description Farmer John has installed a new system of N−1 pipes to transport milk between the N stalls in his barn (2≤N≤50,000), c…
[BZOJ4391][Usaco2015 dec]High Card Low Card(贪心) 题面 BZOJ 题解 预处理前缀后缀的结果,中间找个地方合并就好了. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<set> using na…
[Usaco2015 dec]Max Flow Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 353  Solved: 236[Submit][Status][Discuss] Description Farmer John has installed a new system of N−1 pipes to transport milk between the N stalls in his barn (2≤N≤50,000), conveni…
题意: T,A,B.T是上限.A和B可以随意吃但是不能超过T.有一次将吃的东西/2的机会.然后可以继续吃,不能超过T.问最多可以吃多少. =>我们先处理不能/2可以吃到哪些.然后弄个双指针扫一扫就可以了TAT #include<cstdio> #include<cstring> #include<cctype> #include<algorithm> using namespace std; #define rep(i,s,t) for(int i=s…
BZOJ4390: [Usaco2015 dec]Max Flow Description Farmer John has installed a new system of N−1 pipes to transport milk between the N stalls in his barn (2≤N≤50,000), conveniently numbered 1…N. Each pipe connects a pair of stalls, and all stalls are conn…
bzoj4396[Usaco2015 dec]High Card Wins 题意: 一共有2n张牌,Alice有n张,Bob有n张,每一局点数大的赢.知道Bob的出牌顺序,求Alice最多能赢几局.n≤50000. 题解: 贪心.将Alice和Bob的牌按点数大小排序,然后如果Alice当前牌能赢Bob当前牌就ans++否则就不断调整Bob的当前牌直到Alice当前牌能赢Bob当前牌. 代码: #include <cstdio> #include <cstring> #includ…