传送门 解题思路 这道题要用到贪心的思路,首先要枚举一个h的最大值,之后check.如果这个东西的w[i]与h[i]都大于枚举的值就直接return false,如果w[i]比这个值小,h[i]比这个值大,就将h[i]与w[i]交换,注意并不能直接交换因为后面还要用到,要在答案中将h[i]加上.如果交换次数比n/2大也return false,如果w[i]与h[i]均比这个值小,则将w[i]-h[i]加入数组.后面将它排序,选出可以被交换的更新答案. 代码 #include<iostream>…
题目大意: 有n个矩形在地上排成一列,不可重叠,已知他们的宽度w和高度h,现在使至多[n / 2]个矩形旋转90度,问最后可以用多小的矩形恰好覆盖这n个矩形,求满足条件的最小矩形面积. n, w, h <= 1000. 分析: 数据范围比较小,可以枚举答案矩形的高度H,判断是否能只旋转至多[n / 2]个矩形使得n个矩形的高度均不超过H,再用剩下的操作次数尽量使得总宽度变少. 贪心旋转,尽量把w比h大很多的矩形旋转,所以可以对矩形按照{w - h}排序,贪心旋转即可. #include<cst…
贪心枚举最后方案中最大的h,设为maxh若某个人i的wi与hi均大于maxh,则此方案不可行若某个人恰有一个属性大于maxh,则可确定他是否换属性剩下的人按wi-hi从大到小排序后贪心选择O(nlogn+n2) #include<iostream> #include<cstdio> #include<vector> #include<algorithm> using namespace std; ; int n,w[maxn],h[maxn],hh,ans=…
AK爷GhostCai的电脑又蓝屏了Orz 贪心题,确定一个maxh,限定h不大于一个值.枚举maxh. check的时候的细节很多: 1.h>maxh但w<maxh交换的时候需要占用交换名额. 2.cnt<0了就应该return -1了... 突然忘记还有啥细节 代码如下 #include <iostream> #include <algorithm> #include <cstdio> using namespace std; const int…
Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following: The number of people in each row must be N/K (round down to the nearest integer), with all the extra people (if any) standing in…
Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following: The number of people in each row must be N/K (round down to the nearest integer), with all the extra people (if any) standing in…
Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following: The number of people in each row must be N/K (round down to the nearest integer), with all the extra people (if any) standing in…
1109 Group Photo (25 分) Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following: The number of people in each row must be N/K (round down to the nearest integer), with all the extra peop…
1109 Group Photo(25 分) Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following: The number of people in each row must be N/K (round down to the nearest integer), with all the extra peopl…
Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following: The number of people in each row must be N/K (round down to the nearest integer), with all the extra people (if any) standing in…
Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following: The number of people in each row must be N/K (round down to the nearest integer), with all the extra people (if any) standing in…
Source: PAT A1109 Group Photo (25 分) Description: Formation is very important when taking a group photo. Given the rules of forming K rows with Npeople as the following: The number of people in each row must be / (round down to the nearest integer),…
Formation is very important when taking a group photo. Given the rules of forming K rows with Npeople as the following: The number of people in each row must be / (round down to the nearest integer), with all the extra people (if any) standing in the…
Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following: The number of people in each row must be / (round down to the nearest integer), with all the extra people (if any) standing in th…
简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<queue> #include<stack> #include<string> #include<algorithm> #include<iostream> using namespace std…
题意:n个人,要拍成k行排队,每行 n/k人,多余的都在最后一排. 从第一排到最后一排个子是逐渐增高的,即后一排最低的个子要>=前一排的所有人 每排排列规则如下: 1.中间m/2+1为该排最高: 2.其他人按各自降序顺序,轮流排到中间最高的左边和右边: 举个例子 190 188 186 175 170 — — 190 — — — 188 190 — — — 188 190 186 — 175 188 190 186 — 175 188 190 186 170 3.当个子一样高时,名字按字典序顺序…
题意: 输入两个整数N和K(N<=1e4,K<=10),分别表示人数和行数,接着输入N行每行包括学生的姓名(八位无空格字母且唯一)和身高([30,300]的整数).按照身高逆序,姓名字典序升序将学生从高到矮排列,将学生均分为N行输出,最先输出的一行人数包括除不尽的余数学生,每行中间(如果这一行学生人数为偶数则靠右的为中间)的学生最高,然后依次左边一位学生最高,右边一位学生最高,例如190, 188, 186, 175, 170->175, 188, 190, 186, 170. tric…
\(\mathcal{Description}\)   Link (hard) & Link (easy).   这是一道交互题.   给定一棵 \(n\) 个结点的树,其中有两个是特殊结点.每次你可以提出形如 \(x~c_1~c_2~\cdots~c_x\) 的询问,交互器会回答在点集 \(\{c_x\}\) 中,到两个特殊结点距离之和最小的结点 \(p\) 和这个最小距离和 \(d\)(若有多个 \(d\),回答任意一个).你需要猜出两个特殊结点的编号.   \(n\le10^3\),\(T…
B. Photo to Remember Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/522/problem/B Description One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together…
7月8号晚上8点和两位巨佬开了一场虚拟cf: [Helvetic Coding Contest 2018 online mirror (teams allowed, unrated)] 我这么蔡,只AC了A2.C1.C2.E1(被巨佬吊打) 我就说一下我写的几道题吧: A2. Death Stars (medium) The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. T…
往下看之前一定要先看 %MAVEN_HOME%/conf/settings.xml 配置文件的是否更改了,是否配置正确 <mirror> <id>nexus</id> <url>http://maven.xxxxxx.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> <!-- <mirror&g…
Hbase总结(一)-hbase命令 下面我们看看HBase Shell的一些基本操作命令,我列出了几个常用的HBase Shell命令,如下: 名称 命令表达式 创建表 create '表名称', '列名称1','列名称2','列名称N' 添加记录 put '表名称', '行名称', '列名称:', '值' 查看记录 get '表名称', '行名称' 查看表中的记录总数 count  '表名称' 删除记录 delete  '表名' ,'行名称' , '列名称' 删除一张表 先要屏蔽该表,才能对…
PCF是一个PAAS平台 注册PCF账号 https://account.run.pivotal.io/sign-up 安装cf CLI 访问 https://console.run.pivotal.io/tools 或 https://github.com/cloudfoundry/cli 下载cf CLI 安装下载好的rpm包 # rpm -Uvh cf-cli-installer_6..0_x86-.rpm 查看cf CLI帮助 # cf -h NAME: cf - A command l…
安装环境: 操作系统:    Ubuntu 12.4 LTS 英文 数据库:        mysql5.5.32 web服务器: nginx1.4.1 首先, 添加git和nginx的ppa,并升级系统到最新. sudo apt-add-repository ppa:git-core/ppa sudo add-apt-repository ppa:nginx/stable Software Up to Date 然后, 安装vim,并设为默认编辑器. # Install vim and set…
To get started with Docker CE on CentOS, make sure you meet the prerequisites, then install Docker. Prerequisites Docker EE customers To install Docker Enterprise Edition (Docker EE), go to Get Docker EE for CentOS instead of this topic. To learn mor…
1.导入依赖包 <dependency> <groupId>io.netty</groupId> <artifactId>netty-all</artifactId> <version>5.0.0.Alpha1</version> </dependency> 2.netty服务端代码 public class NettyServer { public static void main(String[] args…
错误信息 This error occurs when you employ a plugin that Maven could not download. Possible causes for this error are: You are referring to a non-existing plugin, e.g. by means of a typo in its group id, artifact id or version. You are using a third-part…
一,操作命令 01,启动gpstart 参数说明 COMMAND NAME: gpstart Starts a Greenplum Database system. ***************************************************** SYNOPSIS ***************************************************** gpstart [-d <master_data_directory>] [-B <para…
安装环境: OS: Oracle linux 5.6 JDK: jdk1.6.0_18 Hadoop: hadoop-0.20.2 Hbase: hbase-0.90.5 安装准备: 1. Jdk环境已安装:版本为1.6以上 2. hadoop环境已安装:完全分布模式安装如下 http://blog.csdn.net/lichangzai/article/details/8206834 3. hbase版本选择 Hbase 版本必需与 Hadoop版本匹配,否则会安装失败或不能正常使用.关于两者…
安装环境: OS: Centos 6.5 JDK: jdk1.6.0_18 Hadoop: hadoop-0.20.2 Hbase: hbase-0.90.5 安装准备: 1.       Jdk环境已安装:版本号为1.6以上 2.       hadoop环境已安装:全然分布模式安装例如以下 http://blog.csdn.net/lichangzai/article/details/8206834 3.       hbase版本号选择 Hbase 版本号必需与 Hadoop版本号匹配,否…