题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4190 Distributing Ballot Boxes Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1065    Accepted Submission(s): 536 Problem Description Today, bes…
题意:给出n个城市,n个城市分别的居民,m个盒子,为了让每个人都投上票,问每个盒子应该装多少张票 二分盒子装的票数, 如果mid<=m,说明偏大了,r应该向下逼近 ,r=mid 如果mid>m,说明偏小了,l应该向上逼近,l=mid+1 和上午那个切割木块那个一样----------- #include<iostream> #include<cstdio> #include<cstring> #include <cmath> #include&l…
Distributing Ballot Boxes Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 756    Accepted Submission(s): 372 Problem Description Today, besides SWERC'11, another important event is taking plac…
Distributing Ballot Boxes http://acm.hdu.edu.cn/showproblem.php?pid=4190 Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2109    Accepted Submission(s): 1119 Problem Description Today, besides…
题目传送门 /* 贪心/二分查找:首先对ai%=p,然后sort,这样的话就有序能使用二分查找.贪心的思想是每次找到一个aj使得和为p-1(如果有的话) 当然有可能两个数和超过p,那么an的值最优,每次还要和an比较 注意:不能选取两个相同的数 反思:比赛时想到了%p和sort,lower_bound,但是还是没有想到这个贪心方法保证得出最大值,还是题目做的少啊:( */ #include <cstdio> #include <algorithm> #include <cst…
The link to problem:Problem - D - Codeforces   D. Range and Partition  time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Given an array a of n integers, find a range of values [x,y] (x≤y…
C. GukiZ hates Boxes Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/551/problem/C Description Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way. In total there…
题意 一个长度$n<=1e5$的数轴,$m<=1e5$个操作 有两种一些操作 $0$  $x$ 在$x$放一个食物 $1$ 一个虫子去吃最近的食物,如果有两个食物一样近,不转变方向的去吃 虫子一开始在$0$点,没吃的就不动 求最终虫子跑了多远? 解法: 用数组维护每个地点有几个食物, 用树状数组维护数轴区间和,每次对于左右进行二分区间求和,找到左右最近的那个点,取最小值即可 #include <bits/stdc++.h> #define ll long long #define…
题目描述 给出一个正整数x,问x最少能由多少个Fibonacci数加减算出. 例如1070=987+89-5-1,因此x=1070时答案是4. 输入 第一行一个正整数q (q<=10),表示有q组输出. 下面q行每行一个正整数x (x<=4*10^17). 输出 输出q行,依次表示每个输出的答案. 样例输入 1 1070 样例输出 4   因为f[i]=f[i-1]+f[i-2],f[i+1]=f[i]+f[i-1],能得到2f[i]=f[i+1]+f[i-2],所以最优答案一定存在没有一个F…
[题目链接]click here~~ [题目大意]在给定 的数组里选两个数取模p的情况下和最大 [解题思路]: 思路见官方题解吧~~ 弱弱献上代码: Problem : 5265 ( pog loves szh II ) Judge Status : Accepted RunId : 13961817 Language : G++ Author : javaherongwei Code Render Status : Rendered By HDOJ G++ Code Render Versio…