目录 @description@ @solution@ @accepted code@ @details@ @description@ n 个竹子,第 i 个竹子初始高度 hi,在每天结束时将长高 ai. 一共 m 天,每天可以砍伐 k 次,可以多次砍伐同一个竹子.如果砍伐的竹子当前高度 h,则砍后变为 max(0, h - p). 问 m 天之后最高的竹子的高度最小是多少. 原题传送门. @solution@ 考虑第 i 个竹子如果在第 j 天被砍了 \(c_{i,j}\) 次,则最后剩下的高…
分析 代码 #include<bits/stdc++.h> using namespace std; #define int long long ],h[],now[],cnt[]; inline bool ck(int mid){ ,res=; ;i<=n;i++)now[i]=h[i]+a[i]*m,tot+=max(0ll,(now[i]-mid-+p)/p); ;i<=m;i++)cnt[i]=; ; ;i<=n;i++)if(now[i]>mid) )%p+;…
题面传送门 首先很显然的一点是,看到类似于"最大值最小"的字眼就考虑二分答案 \(x\)(这点我倒是想到了) 然鹅之后就不会做了/wq/wq/wq 注意到此题正着处理不太方便,故考虑倒着处理,那么原题相当于,初始 \(b_i=x\),每次操作有以下步骤: \(\forall i,b_i\leftarrow b_i-a_i\) 并且要求修改过后的 \(b_i\geq 0\) 选择 \(k\) 个 \(b_i\) 并将它们加上 \(p\) 要求最后 \(\forall i,b_i\geq…
Mr. Kitayuta vs. Bamboos 题目链接:http://codeforces.com/problemset/problem/505/E 参考:http://blog.csdn.net/qpswwww/article/details/46316647 贪心,二分 从数据规模上看,算法复杂度只能为O(n)或者O(nlgn),似乎不能直接求值,考虑二分MAX将求值问题转化为判定性问题.然而考虑到砍伐后竹子高度变为0的特殊情况,考虑倒着做,即初始时每个竹子高度均为MAXi,每天晚上每个…
「CF505E」 Mr. Kitayuta vs. Bamboos 传送门 如果没有每轮只能进行 \(k\) 次修改的限制或者没有竹子长度必须大于 \(0\) 的限制那么直接贪心就完事了. 但是很遗憾. 首先看到最小化最大值可以想到用二分将最优化问题转化为判定性问题. 设当前二分的值为 \(H\). 但是有这个必须大于 \(0\) 的限制很烦,导致我们不一定能真的减少 \(p\),所以我们考虑让时光倒流. 即:假设所有的竹子最后都满足限制,即均为 \(H\).每一次长高就相当于减少 \(a_i\…
Mr. Kitayuta's Colorful Graph Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 505B Description Mr. Kitayuta has just bought an undirected graph consisting of n vertices and m edges. The…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Mr. Kitayuta's Colorful Graph Mr. Kitayuta has just bought an undirected graph consisting of n vertices and m edges. The vertices of the graph are numbered from 1 to n. Each edge, namely edge…
Description The Shuseki Islands are an archipelago of 30001 small islands in the Yutampo Sea. The islands are evenly spaced along a line, numbered from 0 to 30000 from the west to the east. These islands are known to contain many treasures. There are…
A. Mr. Kitayuta's Gift time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly…
题目链接  Mr. Kitayuta's Colorful Graph 把每种颜色分开来考虑. 所有的颜色分为两种:涉及的点的个数 $> \sqrt{n}$    涉及的点的个数 $<= \sqrt{n}$ 对于第一种颜色,并查集缩点之后对每个询问依次处理过来若两点连通则答案加一. 对于第二种颜色,并查集缩点之后对该颜色涉及的所有点两两之间判断是否连通, 若连通则另外开一个$map$记录答案. 最后把两个部分的答案加起来即可. 细节问题  由于每种颜色处理完之后并查集都要重新初始化,对于第一种…