【CF1243A】Maximum Square【贪心】】的更多相关文章

E - Maximum Square Time Limit:4500MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Practice UVALive 4867 Description Given an NxM matrix of all 1s and 0s, find the largest submatrix which is a square containing all 1s. Input Ther…
A. Maximum Square Ujan decided to make a new wooden roof for the house. He has…
题意:给你n个长度为ai的木板,求最大能拼成的矩形为多大 题解:显然贪心每次选最大的进去拼,那么剧需要枚举矩形长度x,看最长的k个能够拼出长度为x的矩形即可 #include<iostream> #include<cstdio> #include<cstdlib> #include<algorithm> #include<cmath> using namespace std; int T,n; ]; int main() { scanf(&quo…
Ujan decided to make a new wooden roof for the house. He has nn rectangular planks numbered from 11 to nn. The ii-th plank has size ai×1ai×1 (that is, the width is 11 and the height is aiai). Now, Ujan wants to make a square roof. He will first choos…
整整10个月后第二次搞这个问题才搞懂........第一次还是太随意了. 解题思路: 经过打表可得规律答案要么是0 要么是2的N次 - 1 要得到最大的XOR值,其值一定是2的N次 - 1 即在 l 和 r 的二进制中,从左到右遍历过去,如果碰到 (2 ^ i) & l 为 1 , (2 ^ i) & r 为 0 即在 l 和 r 之间一定存在 形如 10+ 和01+这样的数. 则可说明在[l , r]中存在 1000000000 和 0111111111 可得到最大XOR值为2的N次 -…
Description Steph is extremely obsessed with “sequence problems” that are usually seen on magazines: Given the sequence 11, 23, 30, 35, what is the next number? Steph always finds them too easy for such a genius like himself until one day Klay comes…
题意:给定一个序列,让你构造出一个序列,满足条件,且最大.条件是 选取一个ai <= max{a[b[j], j]-j} 析:贪心,贪心策略就是先尽量产生大的,所以就是对于B序列尽量从头开始,由于数据比较大,采用桶排序,然后维护一个单调队列,使得最头上最大. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #i…
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=6047 题目: Maximum Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 90    Accepted Submission(s): 44 Problem Description Steph is extremely o…
题目链接:http://codeforces.com/contest/353/problem/C 题意:给你一串数字a[]和一个二进制串,要求找一个不超过m的二进制数,使得与对应a[]上的数字的乘积和最大.输出最大的和. 贪心地找,先求出所有对应数字位都取到的时候的和为初始答案值,接下来从低到高统计a[]的前k项和,当二进制串的第k项为1的时候,我们把这一位的1变成0,这个时候就可以取比它低位的所有数字,并且也能取比它高位的对应原来的二进制串的数字了,这样更新出来就是答案. #include <…
题意:给定 n 个数,问你连续的最长的序列是几个. 析:从头扫一遍即可. 代码如下: #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set> #include <queue> #include <algorith…