Submission #3429833


Source Code Expand

n,c=map(x->parse(Int,x),split(readline()))
L=R=Rmax=Lmax=0
x=[]
v=[]
for i=1:n
	X,V=map(x->parse(Int,x),split(readline()))
	push!(x,X)
	push!(v,V)
	L+=V
end
ans=L-x[n]
for i=n:-1:1
	L-=v[i]
	R+=v[i]
	Rmax=max(Rmax,R-c+x[i])
	ans=max(ans,L-(i>1?x[i-1]*2:0)+Rmax)
end
for i=1:n
	L+=v[i]
	R-=v[i]
	Lmax=max(Lmax,L-x[i])
	ans=max(ans,R-(i<n?(c-x[i+1])*2:0)+Lmax)
end
println(ans)

Submission Info

Submission Time
Task D - Static Sushi
User kotatsugame
Language Julia (0.5.0)
Score 500
Code Size 398 Byte
Status AC
Exec Time 1732 ms
Memory 169104 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 926 ms 169104 KB
a02 AC 412 ms 111196 KB
a03 AC 409 ms 111380 KB
a04 AC 408 ms 108812 KB
b05 AC 407 ms 109352 KB
b06 AC 407 ms 112104 KB
b07 AC 407 ms 109112 KB
b08 AC 407 ms 109364 KB
b09 AC 410 ms 111240 KB
b10 AC 408 ms 110120 KB
b11 AC 410 ms 110344 KB
b12 AC 409 ms 111408 KB
b13 AC 408 ms 110320 KB
b14 AC 407 ms 111076 KB
b15 AC 408 ms 111212 KB
b16 AC 411 ms 109548 KB
b17 AC 408 ms 110852 KB
b18 AC 409 ms 110548 KB
b19 AC 409 ms 109780 KB
b20 AC 409 ms 114812 KB
b21 AC 409 ms 112276 KB
b22 AC 408 ms 112772 KB
b23 AC 408 ms 111264 KB
b24 AC 408 ms 109168 KB
b25 AC 408 ms 111060 KB
b26 AC 408 ms 109180 KB
b27 AC 409 ms 110336 KB
b28 AC 409 ms 112776 KB
b29 AC 409 ms 109784 KB
c30 AC 1613 ms 159272 KB
c31 AC 1696 ms 160216 KB
c32 AC 1708 ms 157680 KB
c33 AC 1721 ms 160628 KB
c34 AC 1689 ms 162160 KB
c35 AC 1596 ms 162696 KB
c36 AC 1732 ms 157692 KB
c37 AC 1690 ms 159304 KB
c38 AC 1694 ms 160308 KB
c39 AC 1714 ms 161424 KB
c40 AC 1691 ms 160896 KB
c41 AC 1708 ms 160468 KB
c42 AC 1706 ms 161152 KB
c43 AC 513 ms 123660 KB
c44 AC 1705 ms 157588 KB
c45 AC 417 ms 111324 KB
c46 AC 1688 ms 161164 KB
c47 AC 410 ms 109168 KB
c48 AC 1704 ms 159660 KB
c49 AC 1708 ms 162068 KB
c50 AC 1689 ms 159236 KB