# L1-049 天梯赛座位分配 (20分)(C++) *

## 题目详情：

L1-049 天梯赛座位分配 (20分)

3
3 4 2

## 输出样例：

#1
1 4 7 10 13 16 19 22 25 28
31 34 37 40 43 46 49 52 55 58
61 63 65 67 69 71 73 75 77 79
#2
2 5 8 11 14 17 20 23 26 29
32 35 38 41 44 47 50 53 56 59
62 64 66 68 70 72 74 76 78 80
82 84 86 88 90 92 94 96 98 100
#3
3 6 9 12 15 18 21 24 27 30
33 36 39 42 45 48 51 54 57 60

## 代码：

#include<bits/stdc++.h>
using namespace std;

int main(){
int n,max = 0,apple = 1,hang;
cin >> n;
int dot = n,count = 0;
int** school = new int*[n];
int* num = new int[n];
bool* flag = new bool[n];
bool first = false;
for(int i = 0;i < n;i++){
int x;
cin >> x;
x *= 10;
school[i] = new int[x];
num[i] = x;
max = x > max ? x : max;
flag[i] = true;
}
int k = 1;
for(int j = 0;j < max;j++){
for(int i = 0;i < n;i++){
if(dot > 1){
if(flag[i]){
school[i][j] = k;
if(j == (num[i] - 1)){
flag[i] = false;
dot--;
}
}else{
goto logo;
}
}else{
if(flag[i]){
if(first != true){
school[i][j] = k;
first = true;
}else{
k++;
school[i][j] = k;
}
}else{
goto logo;
}
}
k++;
logo:
apple = 1;
}
}
for(int i = 0;i < n;i++){
count = 0,hang = 0;
cout << "#" << i + 1 << endl;
for(int j = 0;j < num[i];j++){
if(count != 0){
cout << " ";
}
cout << school[i][j];
count++;
if(count % 10 == 0){
count = 0;
hang++;
if(hang != num[i] / 10){
cout << endl;
}
}
}
cout << endl;
}
return 0;
}


04-01 3429

11-17 425
03-16 924
10-07 1356
02-21 3667
10-04 77
03-19 250