Submission #4030409


Source Code Expand

n,c=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]

rev=[None]*(n+1)
norm=[None]*(n+1)
revmax=[None]*(n+1)

rev[0]=(0,0)
revmax[0]=(0,0)
norm[0]=(0,0)
ans=0

# normal rotation
for i in range(1,n+1):
    x,v=l[i-1]
    norm[i]=(x,v+norm[i-1][1])

# reverse rotation
for i in range(1,n+1)[::-1]:
    x,v=l[i-1]
    if i==n:
        rev[i]=(c-x,v)
    else:
        rev[i]=(c-x,v+rev[i+1][1])

for i in range(1,n+1):
    revmax[-i]=(max(revmax[-i+1][0],rev[-i][1]-2*rev[-i][0]),max(revmax[-i+1][1],rev[-i][1]-rev[-i][0]))

for i in range(n+1):
    v1=norm[i][1]-norm[i][0]+revmax[i-n][0]
    v2=norm[i][1]-2*norm[i][0]+revmax[i-n][1]
    ans=max(ans,v1,v2)

print(ans)

Submission Info

Submission Time
Task D - Static Sushi
User tallestorange
Language Python (3.4.3)
Score 500
Code Size 729 Byte
Status AC
Exec Time 705 ms
Memory 66168 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 300 / 300 200 / 200
Status
AC × 4
AC × 29
AC × 50
Set Name Test Cases
Sample a01, a02, a03, a04
Subtask1 a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29
Subtask2 a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, c30, c31, c32, c33, c34, c35, c36, c37, c38, c39, c40, c41, c42, c43, c44, c45, c46, c47, c48, c49, c50
Case Name Status Exec Time Memory
a01 AC 18 ms 3064 KB
a02 AC 18 ms 3064 KB
a03 AC 18 ms 3064 KB
a04 AC 18 ms 3188 KB
b05 AC 18 ms 3064 KB
b06 AC 18 ms 3064 KB
b07 AC 18 ms 3064 KB
b08 AC 18 ms 3064 KB
b09 AC 19 ms 3064 KB
b10 AC 19 ms 3064 KB
b11 AC 19 ms 3064 KB
b12 AC 19 ms 3064 KB
b13 AC 19 ms 3064 KB
b14 AC 19 ms 3064 KB
b15 AC 19 ms 3064 KB
b16 AC 19 ms 3064 KB
b17 AC 19 ms 3064 KB
b18 AC 19 ms 3064 KB
b19 AC 19 ms 3064 KB
b20 AC 19 ms 3064 KB
b21 AC 19 ms 3064 KB
b22 AC 19 ms 3064 KB
b23 AC 18 ms 3064 KB
b24 AC 18 ms 3064 KB
b25 AC 19 ms 3064 KB
b26 AC 18 ms 3064 KB
b27 AC 19 ms 3064 KB
b28 AC 19 ms 3064 KB
b29 AC 19 ms 3064 KB
c30 AC 688 ms 55144 KB
c31 AC 697 ms 59812 KB
c32 AC 691 ms 66168 KB
c33 AC 668 ms 63024 KB
c34 AC 665 ms 62780 KB
c35 AC 641 ms 55144 KB
c36 AC 668 ms 59840 KB
c37 AC 664 ms 60344 KB
c38 AC 688 ms 60216 KB
c39 AC 682 ms 62200 KB
c40 AC 674 ms 64584 KB
c41 AC 700 ms 60332 KB
c42 AC 674 ms 60916 KB
c43 AC 82 ms 8692 KB
c44 AC 684 ms 61080 KB
c45 AC 25 ms 3572 KB
c46 AC 677 ms 60212 KB
c47 AC 19 ms 3064 KB
c48 AC 669 ms 60476 KB
c49 AC 696 ms 60696 KB
c50 AC 705 ms 62028 KB