题意:

输入一个正整数N(<=10000),表示客户(对)的大小,接着输入N行数据,每行包括一对顾客到场的时间,想要玩的时间,以及是否是VIP客户。接下来输入两个正整数K,M(K<=100,M<=K),表示球桌的数量和其中VIP球桌的数量,接下来输入一行M个正整数,表示VIP球桌的编号。依照每对客户开始打球的时间由小到大顺序输出N行:他们的到场时间和开始打球的时间以及四舍五入输入等待时长,最后一行输出每张球桌服务的客户对数。如果客户21点前没有得到服务,则不输出他们的数据。

trick:

第8组数据包含需要对分钟进行四舍五入的数据,一开始没用翻译采取直接上取整发现这个点过不去。

第3组数据包含恰好21点到达的客户,他们是不可以接受服务的,这个点找了较长时间才发现。

第7组数据包含VIP客户需要先安排到VIP球桌的数据且VIP球桌不空闲的数据。

第5组数据包含VIP客户需要安排到VIP球桌且VIP球桌空闲的数据。

第1,2组数据包含当前无球桌空闲的数据。

第4,6组数据包含当前无VIP客户的数据。

第0组数据即为样例。

(对于数据的揣测基于我提交代码的不同,可能有误,仅希望有缘人可以借此少走弯路)

对于题干最后一句话:

On the other hand, if when it is the turn of a VIP pair, yet no VIP table is available, they can be assigned as any ordinary players.

On the other hand在Codeforces网站上的常用意为换句话说,意思是On the other hand后面的话和上一句话表达的意思是一样的只是换了种说法,这道题中On the other hand的意思应该是另一方面,因为我经常打Codeforces所以刚做题时我习惯地忽略了On the other hand后面的话,这道题的题意确实使这道题蒙上了一些细节方面的理解薄雾。

AAAAAccepted code:

 #define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int table[];
int tt[];
int tans[];
int vipid[];
typedef struct customers{
string s;
int t,pt,ft,flg;
};
customers c[];
typedef struct ans{
string s;
int t,st;
};
ans a[];
bool cmp(customers a,customers b){
return a.t<b.t;
}
bool cmp2(ans a,ans b){
return a.st<b.st;
}
char anss[][];
int main(){
int n;
cin>>n;
for(int i=;i<=n;++i){
cin>>c[i].s>>c[i].pt>>c[i].flg;
if(c[i].pt>=)
c[i].pt=;
c[i].pt*=;
c[i].t=(c[i].s[]-'')*+(c[i].s[]-'')*+(c[i].s[]-'')*+(c[i].s[]-'')*+(c[i].s[]-'')*+c[i].s[]-'';
}
int sum,vip;
cin>>sum>>vip;
int x;
for(int i=;i<=vip;++i){
cin>>x;
table[x]=;
}
sort(c+,c++n,cmp);
int cnt=;
for(int i=;i<=n;++i)
if(c[i].flg)
vipid[++cnt]=i;
int sew=,mn=1e9,pos=;
int cntt=;
for(int i=;i<=n;++i){
if(a[i].t)
continue;
if(c[i].t>=*)
break;
sew=,mn=1e9,pos=;
if(c[i].flg==){
for(int j=;j<=sum;++j){
if(!table[j])
continue;
if(tt[j]<=c[i].t){
tt[j]=c[i].t+c[i].pt;
a[i].s=c[i].s;
a[i].t=c[i].t;
a[i].st=c[i].t;
++tans[j];
sew=;
break;
}
if(tt[j]<mn){
mn=tt[j];
pos=j;
}
}
if(sew)
continue;
for(int j=;j<=sum;++j){
if(tt[j]<=c[i].t){
tt[j]=c[i].t+c[i].pt;
a[i].s=c[i].s;
a[i].t=c[i].t;
a[i].st=c[i].t;
++tans[j];
sew=;
break;
}
if(tt[j]<mn){
mn=tt[j];
pos=j;
}
}
if(sew)
continue;
if(tt[pos]<*){
a[i].st=tt[pos];
tt[pos]+=c[i].pt;
a[i].s=c[i].s;
a[i].t=c[i].t;
++tans[pos];
}
continue;
}
sew=,mn=1e9,pos=;
for(int j=;j<=sum;++j){
if(tt[j]<=c[i].t){
tt[j]=c[i].t+c[i].pt;
a[i].s=c[i].s;
a[i].t=c[i].t;
a[i].st=c[i].t;
++tans[j];
sew=;
break;
}
if(tt[j]<mn){
mn=tt[j];
pos=j;
}
}
if(sew)
continue;
if(table[pos]&&tt[pos]<*){
while(a[vipid[cntt]].t)
++cntt;
if(cntt<=cnt&&c[vipid[cntt]].t<=tt[pos]){
a[vipid[cntt]].st=tt[pos];
tt[pos]+=c[vipid[cntt]].pt;
a[vipid[cntt]].s=c[vipid[cntt]].s;
a[vipid[cntt]].t=c[vipid[cntt]].t;
--i;
++tans[pos];
++cntt;
}
else{
a[i].st=tt[pos];
tt[pos]+=c[i].pt;
a[i].s=c[i].s;
a[i].t=c[i].t;
++tans[pos];
}
}
else if(tt[pos]<*){
a[i].st=tt[pos];
tt[pos]+=c[i].pt;
a[i].s=c[i].s;
a[i].t=c[i].t;
++tans[pos];
}
}
sort(a+,a++n,cmp2);
for(int i=;i<=n;++i){
if(!a[i].t)
continue;
cout<<a[i].s<<" ";
int temp=a[i].st;
anss[i][]=a[i].st/+'';
a[i].st%=;
anss[i][]=a[i].st/+'';
a[i].st%=;
anss[i][]=':';
anss[i][]=a[i].st/+'';
a[i].st%=;
anss[i][]=a[i].st/+'';
a[i].st%=;
anss[i][]=':';
anss[i][]=a[i].st/+'';
a[i].st%=;
anss[i][]=a[i].st+'';
cout<<anss[i]<<" ";
int x=(temp-a[i].t)/;
if((temp-a[i].t)%>=)
++x;
cout<<x<<"\n";
}
for(int i=;i<=sum;++i)
cout<<tans[i]<<((i==sum)?"":" ");
return ;
}

【PAT甲级】1026 Table Tennis (30 分)(结构体排序,trick较多)的更多相关文章

  1. PAT 甲级 1026 Table Tennis (30 分)(坑点很多,逻辑较复杂,做了1天)

    1026 Table Tennis (30 分)   A table tennis club has N tables available to the public. The tables are ...

  2. PAT甲级1026. Table Tennis

    PAT甲级1026. Table Tennis 题意: 乒乓球俱乐部有N张桌子供公众使用.表的编号从1到N.对于任何一对玩家,如果有一些表在到达时打开,它们将被分配给具有最小数字的可用表.如果所有的表 ...

  3. PAT 甲级 1026 Table Tennis(模拟)

    1026. Table Tennis (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A table ...

  4. 1026 Table Tennis (30分) 难度不高 + 逻辑复杂 +细节繁琐

    题目 A table tennis club has N tables available to the public. The tables are numbered from 1 to N. Fo ...

  5. 1026 Table Tennis (30分)

    A table tennis club has N tables available to the public. The tables are numbered from 1 to N. For a ...

  6. PAT甲级1026 Table Tennis【模拟好题】

    题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805472333250560 题意: 有k张乒乓球桌,有的是vip桌 ...

  7. PAT A 1022. Digital Library (30)【结构体排序检索】

    https://www.patest.cn/contests/pat-a-practise/1022 直接模拟, 输入,按id排序,检索 #include <iostream> #incl ...

  8. PAT 甲级 1028. List Sorting (25) 【结构体排序】

    题目链接 https://www.patest.cn/contests/pat-a-practise/1028 思路 就按照 它的三种方式 设计 comp 函数 然后快排就好了 但是 如果用 c++ ...

  9. PAT 甲级 1080 Graduate Admission (30 分) (简单,结构体排序模拟)

    1080 Graduate Admission (30 分)   It is said that in 2011, there are about 100 graduate schools ready ...

随机推荐

  1. Spring JdbcTemplate类常用的方法

    execute(String  sql) 可执行任何sql语句,但返回值是void,所以一般用于数据库的新建.修改.删除和数据表记录的增删改. int  update(String sql) int  ...

  2. 如何在JDBC Connection Configuration配置组件上添加控件

    如何在JDBC Connection Configuration配置组件上添加控件 最近项目刚上线,闲来无事又把Jmeter的源码拿出来研究研究,最初的目的是想扒一扒Jmeter里数据库处理的逻辑是怎 ...

  3. 查看并下载MySQL对应jar包

    打开已经安装的mysql文件位置 2.查看对应connector版本并下载jar包 3.下载对应jar包:http://central.maven.org/maven2/mysql/mysql-con ...

  4. java编译器不匹配问题(java compiler level does not match the version of the installed java project facet)

    问题:项目经常copy过来,经常会报说Java编译器不匹配 解决方法:找到项目所在的目录,在.settings子目录里面,用文本编辑器打开org.eclipse.wst.common.project. ...

  5. MySQL导出数据到文件报错

    执行如下语句: mysql> select * from users into outfile "F:\Develop\MySQL57\Uploads\users.txt" ...

  6. jquery-1.10.2_d88366fd.js和jquery-3.1.0.min.js 在用touch事件时候, event.changedTouches[0]报错的问题。

    1.animation动画:(注意如果这个动画是一开始就执行的,在pc端就要用px,在手机端用rem,如果在pc端展示页面,但用的是rem为单位,这时候动画一开始就执行,因为根字体大小还没准备好,动画 ...

  7. 移除微信昵称中的emoji字符

    移除微信昵称中的emoji字符: /** * 移除微信昵称中的emoji字符 * @param type $nickname * @return type */ function removeEmoj ...

  8. jq基础(2)

    jquery的选择器 基本选择器 id选择器:$(“#id名称”); 元素选择器:$(“元素名称”); 类选择器:$(“.类名”); 通配符:* 多个选择器共用(并集) 案例代码: <html& ...

  9. 【代码审计】MenInfo文件包含漏洞

    代码审计是我之前一直不敢涉及的领域,它包含的知识面太广.最近才开始学习,前段时间写的第一篇代码审计的文章 更多的感觉像是一个黑盒测试.我也会尽量把文章写的通俗易懂.代码审计 0基础从大牛的蜕变 从这里 ...

  10. Nexus-vPC相关特性

    vPC Peer-switch: 不开启这功能,只有Primary设备发送BPDU,开启之后,将会把这一对设备呈现为一个STP Root,使用一个MAC地址,那么都可以发送BPDU了.STP BPDU ...