简单模拟。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std; struct X
{
string name;
int h;
} s[+];
int n,k;
vector<int>g[];
int tmp[+]; bool cmp(const X&a,const X&b)
{
if(a.h==b.h) return a.name<b.name;
return a.h>b.h;
} int main()
{
scanf("%d%d",&n,&k);
for(int i=; i<=n; i++)
cin>>s[i].name>>s[i].h;
sort(s+,s+n+,cmp); int t=n+;
for(int i=k; i>=; i--)
{
int m;
if(i>) m=n/k;
else m=n-n/k*(k-);
t=t-m;
int y=t,p=m/+,sz=;
int L,R;
tmp[p]=y++,sz++,L=p-,R=p+;
while()
{
if(sz==m) break;
if(sz%==) tmp[R++]=y++;
else tmp[L--]=y++;
sz++;
}
for(int j=;j<=m;j++) g[i].push_back(tmp[j]); }
for(int i=; i<=k; i++)
{
for(int j=; j<g[i].size(); j++)
{
cout<<s[g[i][j]].name;
if(j<g[i].size()-) printf(" ");
else printf("\n");
}
}
return ;
}

PAT (Advanced Level) 1109. Group Photo (25)的更多相关文章

  1. 【PAT甲级】1109 Group Photo (25分)(模拟)

    题意: 输入两个整数N和K(N<=1e4,K<=10),分别表示人数和行数,接着输入N行每行包括学生的姓名(八位无空格字母且唯一)和身高([30,300]的整数).按照身高逆序,姓名字典序 ...

  2. 1109 Group Photo (25分)

    Formation is very important when taking a group photo. Given the rules of forming K rows with N peop ...

  3. 1109. Group Photo (25)

    Formation is very important when taking a group photo. Given the rules of forming K rows with N peop ...

  4. PAT甲题题解-1109. Group Photo (25)-(模拟拍照排队)

    题意:n个人,要拍成k行排队,每行 n/k人,多余的都在最后一排. 从第一排到最后一排个子是逐渐增高的,即后一排最低的个子要>=前一排的所有人 每排排列规则如下: 1.中间m/2+1为该排最高: ...

  5. PAT (Advanced Level) 1114. Family Property (25)

    简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...

  6. PAT (Advanced Level) 1105. Spiral Matrix (25)

    简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<map> #incl ...

  7. PAT (Advanced Level) 1101. Quick Sort (25)

    树状数组+离散化 #include<cstdio> #include<cstring> #include<cmath> #include<map> #i ...

  8. PAT (Advanced Level) 1071. Speech Patterns (25)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  9. PAT (Advanced Level) 1063. Set Similarity (25)

    读入之后先排序. 询问的时候可以o(m)效率得到答案. #include<cstdio> #include<cstring> #include<cmath> #in ...

随机推荐

  1. Set下面HashSet,TreeSet和LinkedHashSet的区别

    Set接口Set不允许包含相同的元素,如果试图把两个相同元素加入同一个集合中,add方法返回false.Set判断两个对象相同不是使用==运算符,而是根据equals方法.也就是说,只要两个对象用eq ...

  2. buffer小解

    Buffer代表一个缓冲区,存储二进制数据,是字节流 创建: 创建Buffer有4种方式: 1.new Buffer(size) 以字节为单位创建指定大小的Buffer eg: var buf= ne ...

  3. CGridCtrl在MFC中的使用(一)

    CGridCtrl控件是开源的,可在CodePlex和CodeProject上搜索找到,是VC++中用于显示表格数据的控件.基本功能包括:表格显示,单元格的编辑,单元格颜色设置,鼠标事件的响应,单元格 ...

  4. CSS3的box-sizing属性

    盒模型的宽度,在 IE5.x 以及 Quirks 模式的 IE6/7 中,将 border 与 padding 都包含在 width 之内 W3C标准中的盒模型宽度为内容宽度,不包括内边距paddin ...

  5. zookeeper入门知识

    ZooKeeper 是什么? ZooKeeper 顾名思义 动物园管理员,他是拿来管大象(Hadoop) . 蜜蜂(Hive) .小猪(Pig)  的管理员, Apache Hbase和 Apache ...

  6. iOS拨打电话

    1,这种方法,拨打完电话回不到原来的应用,会停留在通讯录里,而且是直接拨打,不弹出提示NSMutableString * str=[[NSMutableString alloc] initWithFo ...

  7. NetBox v2.8下载使用指南

    2008-09-20 11:21:05|  分类: ASP|举报|字号 订阅     NetBox v2.8下载地址: http://down.chinaz.com/soft/13211.htm 安装 ...

  8. HDU2519:新生晚会

    Problem Description 开学了,杭电又迎来了好多新生.ACMer想为新生准备一个节目.来报名要表演节目的人很多,多达N个,但是只需要从这N个人中选M个就够了,一共有多少种选择方法?   ...

  9. 【转】PHP android ios相互兼容的AES加密算法

    APP项目用户密码传输一直没有用HTTPS,考虑到用户的隐私暂时先用AES对密码加密,以后也可以用于手机端与服务端加密交互. PHP的免费版phpAES项目,手机端解码各种不对. 好不容易找了PHP ...

  10. DataSet与DataReader的比较

    DataSet与DataReader的比较 DataSet DataReader 读或写数据 只读 包含多个来自不同数据库的表 使用 SQL 语句从单个数据库 非连接模式 连接模式 绑定到多个控件 只 ...