# 堆积块

15

``````  ####
0123456789
``````

``````    ######
####
``````

``````    ######
####      #
``````

``````    ######
####      #
0011222222001
``````

``````In                                   Out
---------------------------------------------------------
2 4 4 6 12 1                         0011222222001
0 5 9 1 6 4 2 5                      1133333222
0 5 9 1 2 5 6 4                      1122223333
0 5 2 5 6 4 9 1                      1122223334
20 1 20 1 20 1                       00000000000000000003
5 5                                  000011111
0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 4  123456789999
``````

lirtosiast

Doorknob

2

## CJam，34个 30字节

``````Lq~2/{eeWf%e~_2\$:).*:e>f*.e>}/
``````

``````Lq~2/{_:\3\$><0+:e>)aeez.*e_.e>}/
LQ~2/{_:\3\$><0+:e>)aeez.+e~.e>}/
``````

6

## Python 3、89

``````def f(a):
h=[]
while a:x,w,*a=a;h[:x+w]=(h+[0]*x)[:x]+[max(h[x:x+w]+[0])+1]*w
return h``````

``````def f(a):                       # input as list of integers
h=[]                          # list of heights
while a:                      # while there's input left
x,w,*a=a;                   # pop first 2 integers as x and w

h[:x+w]=                    # change the heights between 0 and x+w
(h+[0]*x)[:x]+            # left of x -> unchanged but padded with zeros
[max(h[x:x+w]+[0])+1]*w   # between x and x+w -> set to the previous max + 1

return h                      # return the list of heights``````

2

## 红宝石， 88 87字节

``````f=->i{o=[]
(s,l,*i=i
r=s...s+l
o[r]=[([*o[r]]+[0]).max+1]*l
o.map! &:to_i)while i[0]
o}``````

``````f=->i                        # lambda with parameter i, expects array of ints
{
o=[]                     # output
(
s,l,*i=i             # pop start and length
r = s...s+l          # range is used twice, so shorten it to 1 char
o[r] =
[(
[*o[r]]  # o[r] returns nil if out of bounds, so splat it into another array
+[0]     # max doesn't like an empty array, so give it at least a 0
).max+1]*l       # repeat max+1 to fill length
o.map! &:to_i        # replace nil values with 0
) while i[0]             # i[0] returns nil when i is empty, which is falsy
o                        # return o
}
``````

1

## APL，79个字节

``````{⊃{o←(z←(≢⍵)⌈a←+/⍺)↑⍵⋄e←(z↑(-a)↑⍺[1]⍴1)⋄o+0⌈o-⍨e×e⌈.+e×o}/⌽(⊂⍬),↓(⌽2,0.5×≢⍵)⍴⍵}
``````

`{⊃{o←⍵↑⍨z←(≢⍵)⌈a←+/⍺⋄e←z↑(-a)↑⍺[1]⍴1⋄o+0⌈o-⍨e×e⌈.+e×o}/⌽(⊂⍬),↓⍵⍴⍨⌽2,.5×≢⍵}`（我的上帝，学会使用`⍨`权）

lstefano

lstefano

--是吗？- -`0.5`

0

### 的Java 1.8，351个 329字节

``interface B{static void main(String[]x){Byte b=1;int i=0,s,c,m=0,h,a=x.length,t[];for(;i<a;){s=b.valueOf(x[i++]);c=b.valueOf(x[i++]);m=m>s+c?m:s+c;}t=new int[m];for(i=0;i<a;){h=0;s=b.valueOf(x[i++]);c=b.valueOf(x[i++]);for(m=s;m<s+c;m++)if(t[m]>=h)h=t[m]+1;for(m=s;m<s+c;)t[m++]=h;}for(i=0;i<t.length;)System.out.print(t[i++]);}}``

### 不打高尔夫球

``````interface B {
static void main(String[]x){
int start, count, maxWidth=0, height, args=x.length, totals[];
Byte b=1;
for (int i=0; i<args;){
start = b.valueOf(x[i++]);
count = b.valueOf(x[i++]);
maxWidth = maxWidth>start+count ? maxWidth : start+count;
}
totals=new int[maxWidth];
for (int i=0; i<args;){
height=0;
start = b.valueOf(x[i++]);
count = b.valueOf(x[i++]);
for (int j = start; j<start+count; j++) {
if (totals[j]>=height) {
height=totals[j]+1;
}
}
for (int j = start; j<start+count; j++) {
totals[j] = height;
}
}
for (int i=0;i<totals.length; i++){
System.out.print(totals[i]);
}
}
}``````