CCF 201609-2 火车购票 (C)有人做出来了吗?
ccf吧
全部回复
仅看楼主
level 1
Tempor7 楼主
CCF 201609-2 火车购票 (C)有人做出来了吗?可以发到这里让我学习一下吗?万分感谢[太开心]
2017年03月04日 08点03分 1
level 5
做了
2017年03月09日 07点03分 2
level 5
90分
2017年03月09日 07点03分 3
level 5
有一组数据没过,但是我知道那里错了,有空再改
2017年03月09日 07点03分 4
能说下哪里错了吗,我也是90分,不知道哪错了
2017年03月11日 07点03分
level 5
我的是这样的,当遍历一边没有找到连续的座位满足条件时,应当按照序号安排,例如,当每一排都做了四个人时,如果有五个人买票,找不到5个连续的座位,则安排5 10 15 20
2017年03月11日 07点03分 5
level 5
不知道你是不是忽略了这个
2017年03月11日 07点03分 6
谢谢,我也是这样
2017年03月13日 07点03分
我也90分,测试很多情况都对了,但是就是90分
2017年03月17日 05点03分
level 1
弱渣答案,仅供参考[不高兴]
#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;
int main(){
int n;
int pos[20];
int i,j;
int a[100];
while(cin>>n,!cin.eof()){
for(i=0;i<20;i++)pos[i]=5;
for(i=0;i<n;i++)cin>>a[i];
for(i=0;i<n;i++){
for(j=0;j<20;j++){//是否存在连座
if(pos[j]>=a[i]){
int k;
for(k=0;k<a[i];k++)cout<<(5*j+6-pos[j]+k)<<" ";
cout<<endl;
pos[j]=pos[j]-a[i];
j=25;
}
}
if(j!=26){//不存在连座时
int temp=a[i];
for(j=0;j<20&&temp!=0;j++){
if(pos[j]>0){
int k;
if(temp>=pos[j]){
temp=temp-pos[j];
for(k=0;k<pos[j];k++)cout<<(5*j+6-pos[j]+k)<<" ";
}
else{
for(k=0;k<temp;k++)cout<<(5*j+6-pos[j]+k)<<" ";
cout<<endl;
j=25;
}
}
}
}
}
}
return 0;
}
2017年03月19日 11点03分 7
level 1
这道题90分[黑线]
2017年03月21日 04点03分 8
level 1
http://blog.csdn.net/qq_24369113/article/details/62286987
萌新答案,经供参考,不过还是过了所有的测试用例的
2017年03月21日 08点03分 9
1