问题描述
试题编号: | 201609-2 |
试题名称: | 火车购票 |
时间限制: | 1.0s |
内存限制: | 256.0MB |
问题描述: | 问题描述 请实现一个铁路购票系统的简单座位分配算法,来处理一节车厢的座位分配。 输入格式 输入的第一行包含一个整数n,表示购票指令的数量。 输出格式 输出n行,每行对应一条指令的处理结果。 样例输入 4 样例输出 1 2 样例说明 1) 购2张票,得到座位1、2。 评测用例规模与约定 对于所有评测用例,1 ≤ n ≤ 100,所有购票数量之和不超过100。 |
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<list>
#include<set>
#include<iomanip>
#include<cstring>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cassert>
#include<sstream>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
typedef long long ll;
#define ls (p<<1)
#define rs (p<<1|1)
#define mid (l+r)/2
#define over(i,s,t) for(register long long i=s;i<=t;++i)
#define lver(i,t,s) for(register long long i=t;i>=s;--i)
const int MAXN = 305;
const int INF = 0x3f3f3f3f;
const int N=5e4+7;
const int maxn=1e5+5;
const double EPS=1e-10;
const double Pi=3.1415926535897;
//inline double max(double a,double b){
// return a>b?a:b;
//}
//inline double min(double a,double b){
// return a<b?a:b;
//}
int xd[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int yd[8] = {1, 0, -1, 0, -1, 1, -1, 1};
//void Fire(){
// queue<node> p;
// p.push({fx,fy,0});
// memset(fire, -1, sizeof(fire));
// fire[fx][fy]=0;
// while(!p.empty()){
// node temp=p.front();
// p.pop();
// for(int i=0;i<8;i++){
// int x=temp.x+xd[i];
// int y=temp.y+yd[i];
// if(x<0||x>=n||y<0||y>=m||fire[x][y]!=-1){
// continue;
// }
// fire[x][y]=temp.val+1;
// p.push({x,y,temp.val+1});
// }
// }
//}
//int bfs(){
// queue<node> p;
// memset(vis, 0, sizeof(vis));
// p.push({sx,sy,0});
// while (!p.empty()) {
// node temp=p.front();
// vis[temp.x][temp.y]=1;
// p.pop();
// for(int i=0;i<4;i++){
// int x=temp.x+xd[i];
// int y=temp.y+yd[i];
// if(x<0||x>=n||y<0||y>=m) continue;
// if(x==ex&&y==ey&&temp.val+1<=fire[x][y]) return temp.val+1;
// if(vis[x][y]||temp.val+1>=fire[x][y]||a[x][y]=='#') continue;
// p.push({x,y,temp.val+1});
// }
// }
// return -1;
//}
int n;
int a[110];
int b[110][6];
int main(){
cin>>n;
int x;
for(int i=0;i<20;i++){
a[i]=5;
}
for(int i=0;i<20;i++){
for(int j=0;j<5;j++){
b[i][j]=1;
}
}
while (n--) {
cin>>x;
int m;
for(int i=0;i<20;i++){
if(a[i]>=x){
for(int j=5-a[i];j<5-a[i]+x;j++){
cout<<j+1+i*5<<" ";
}
a[i]-=x;
cout<<endl;
m=0;
break;
}
}
}
}