cf B. Fence】的更多相关文章

http://codeforces.com/contest/363/problem/B #include <cstdio> #include <cstring> #include <algorithm> #define maxn 500001 using namespace std; <<; int n,k; int a[maxn]; int min1; int sum[maxn]; int main() { while(scanf("%d%d&q…
E. Sign on Fence time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Bizon the Champion has recently finished painting his wood fence. The fence consists of a sequence of n panels of 1 meter w…
Bizon the Champion has recently finished painting his wood fence. The fence consists of a sequence of n panels of 1 meter width and of arbitrary height. The i-th panel's height is hi meters. The adjacent planks follow without a gap between them. Afte…
http://codeforces.com/contest/484/problem/E 题意: 给出n个数,查询最大的在区间[l,r]内,长为w的子区间的最小值 第i棵线段树表示>=i的数 维护最长连续子区间 把数从大到小插入主席树 对于每个询问,二分x 在第x棵线段树中查,若最长连续子区间>=w,到代表更大的线段树中查 没有建第n+1棵线段树,导致前面节点的siz不对,WA了一次 #include<cstdio> #include<iostream> #include…
http://codeforces.com/contest/349/problem/B 贪心 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; <<; ]; int v,k; int main() { while(scanf("%d",&v)!=EOF) { int min1=inf; k=; ; i<=; i++)…
http://codeforces.com/problemset/problem/448/C 题目大意:给你一个栅栏,每次选一横排或竖排染色,求把全部染色的最少次数,一个点不能重复染色. 和这道题有点像,不过可以竖着. 考虑横着涂一次的情况,那么有两个显而易见的事实. 1.这次涂色长度必须尽可能大. 2.在这次涂色区域的下方,必定都是横着涂的. 所以,对于一串栅栏h 1 , h 2 , ... , h n ,如果要横着涂,就必定要从底向上涂min⁡{h 1 , h 2 , ... , h n }…
因为cf上一堆水题,每个单独开一篇博客感觉不太好,就直接放一起好了. CF1096D Easy Problem 给定字符串,每个位置删除要代价.求最小代价使之不含子序列"hard". 设f[i][f]表示前i个删到只匹配f位子序列的最小代价.转移看代码吧.O(n) #include <bits/stdc++.h> typedef long long LL; ; int a[N]; LL f[N][]; char str[N]; int main() { int n; sca…
1. CF 438D The Child and Sequence 大意: n元素序列, m个操作: 1,询问区间和. 2,区间对m取模. 3,单点修改 维护最大值, 取模时暴力对所有>m的数取模. 因为取模后至少减半, 复杂度$O(nlognlogC)$ 2. CF 431E Chemistry Experiment 大意: n个试管, 第$i$个试管有$a_i$单位水银, m个操作: 1, 修改$a_x$改为$v$. 2, 将$v$单位水倒入试管, 求一种方案使得有水的试管水银与水总量的最大…
[CF484E]Sign on Fence(主席树) 题面 懒得贴CF了,你们自己都找得到 洛谷 题解 这不就是[TJOI&HEOI 排序]那题的套路吗... 二分一个答案,把大于答案的都变成\(1\),其余变成\(0\) 按照题目要求的区间内连续的\(K\)个 就是检查最长的连续\(1\)的子段长度大于\(K\) 所以维护\(1\)的子段长度(这也是原题吧??) 因为范围比较大,不能每次开线段树计算 我们发现每次将范围增大的时候,在线段树上可以直接做一定的修改 又因为要维护所有的线段树,所以直…
Discription Richard just finished building his new house. Now the only thing the house misses is a cute little wooden fence. He had no idea how to make a wooden fence, so he decided to order one. Somehow he got his hands on the ACME Fence Catalogue 2…