Magazine Ad 题目链接:http://codeforces.com/contest/803/problem/D ——每天在线,欢迎留言谈论. 题目大意: 给你一个数字k,和一行字符 例: garage for sa-le 其中这行字符串能够在 ' '与'-'的后面分割.例如分割为:(点代表空格) garage. for. sa- le 求:分割成不超过k行的情况下的最小宽度.(宽度:最大行的字符个数) 思路: 答案一定在 到 所给字符串长度 之间. ①通过二分宽度 来逼近最小宽度. 判…
codeforces.com/contest/803/problem/D [题意] 给定一个字符串,字符串里可能有空格和连字符‘-’,空格和连字符的意义是一样的,都表示:能在那个位置把字符串分成两部分,且两部分分到两行去,空格或连字符留在当前行. 这个分裂操作能够使得原字符串不断变短; 问你最后获得的所有字符串(可能分裂成了多行,所以是”所有”)中最长的那个最短能够是多少: 分裂操作最多只能操作k次: [思路] 这种题已经做过多次了,要找最长的那个最短的,直接二分查找最短值,每次贪心划分,看总行…
二分. 首先把字符串处理成一个数组,二分答案,判断一下即可. #include <cstdio> #include <cmath> #include <set> #include <cstring> #include <algorithm> using namespace std; int p; int a[1000010],sz; char s[1000010]; void work() { int sum=0; for(int i=0;s[i…
Magazine Ad The main city magazine offers its readers an opportunity to publish their ads. The format of the ad should be like this: There are space-separated non-empty words of lowercase and uppercase Latin letters. There are hyphen characters '-' i…
803D - Magazine Ad 思路: 二分答案+贪心: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 1000006 int k,ai[maxn],cnt,num,len,maxlen; char ch[maxn]; bool check(int lit) { ,ti…
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…
D. Magazine Adtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe main city magazine offers its readers an opportunity to publish their ads. The format of the ad should be like this: There are spac…
F - 贪心+ 二分 Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu   Description   A set of n<tex2html_verbatim_mark> 1-dimensional items have to be packed in identical bins. All bins have exactly the same length l<tex2html_ver…
Card Game Cheater Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1566    Accepted Submission(s): 822 Problem Description Adam and Eve play a card game using a regular deck of 52 cards. The rule…
Heap Partition Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge A sequence S = {s1, s2, ..., sn} is called heapable if there exists a binary tree T with n nodes such that every node is labelled with exactly one element from the se…